Skip to content

Commit

Permalink
#43 Fix concention code
Browse files Browse the repository at this point in the history
  • Loading branch information
bfoujols committed Dec 29, 2023
1 parent f4d182f commit 10a861b
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 16 deletions.
20 changes: 10 additions & 10 deletions src/EduFramework/Commands/CreateControllerCommand.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,16 +74,16 @@ private function getNamesCollection(string $arg): array
$uri = "/".strtolower($arg);
$twig = strtolower($arg);

if(count($pieces)>1) {
if(count($pieces) > 1) {
$twig = implode("_", array_map(function ($item) {return strtolower($item);}, $pieces));
$uri = str_replace("_", "-", $twig);
}

return [
"uri"=>$uri,
"twigDir"=>$twig,
"twigPath"=>"$twig/$twig.html.twig",
"className"=>$className
"uri" => $uri,
"twigDir" => $twig,
"twigPath" => "$twig/$twig.html.twig",
"className" => $className
];
}

Expand All @@ -104,7 +104,7 @@ private function generateController(string $className, string $twigPath): void

$file = new PhpFile();
//Add namespace Controller
$namespace= $file->addNamespace("Controller");
$namespace = $file->addNamespace("Controller");
//Add Imports
$namespace->addUse('Studoo\EduFramework\Core\Controller\ControllerInterface');
$namespace->addUse('Studoo\EduFramework\Core\Controller\Request');
Expand Down Expand Up @@ -150,10 +150,10 @@ private function generateRoute(string $name, string $uri, string $className): vo
throw new RouteAlreadyExistsException();
}

$router[$name]=[
"uri"=>"/".$uri,
"controller"=>'Controller\\'.$className,
"httpMethod"=>["GET"]
$router[$name] = [
"uri" => "/".$uri,
"controller" => 'Controller\\'.$className,
"httpMethod" => ["GET"]
];

file_put_contents(self::ROUTES_FILE_PATH, Yaml::dump($router));
Expand Down
27 changes: 21 additions & 6 deletions src/EduFramework/Core/View/StudooDebugExtension.php
Original file line number Diff line number Diff line change
@@ -1,33 +1,48 @@
<?php
/*
* Ce fichier fait partie du edu-framework.
* Ce fichier fait partie du Studoo
*
* (c) Studoo
* @author Benoit Foujols
*
* Pour les informations complètes sur les droits d'auteur et la licence,
* veuillez consulter le fichier LICENSE qui a été distribué avec ce code source.
*/


namespace Studoo\EduFramework\Core\View;

use Twig\Extension\AbstractExtension;

/**
* Class StudooDebugExtension
* Elle permet de déclarer les fonctions de l'extension dd()
* @package Studoo\EduFramework\Core\View
*/
class StudooDebugExtension extends AbstractExtension
{
/**
* Permet de déclarer les fonctions de l'extension
* @return \Twig\TwigFunction[]
*/
public function getFunctions(): array
{
return [
new \Twig\TwigFunction('dd', [$this, 'dd']),

Check notice on line 29 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L29

Array value not aligned correctly; expected 16 spaces but found 12
];

Check notice on line 30 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L30

Closing parenthesis not aligned correctly; expected 15 space(s) but found 8
}

public function dd($var): void
/**
* Permet d'afficher le contenu d'une variable
* @param string $var

Check notice on line 35 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L35

Missing parameter comment
* @return void
*/
public function dd(string $var): void

Check notice on line 38 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L38

Avoid using short method names like StudooDebugExtension::dd(). The configured minimum method name length is 3.
{
ob_start();
var_dump($var);

Check warning on line 41 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L41

The use of function var_dump() is discouraged
$result = ob_get_clean();

echo "<div style=\"background-color: grey; color: white; padding: 10px; margin: 10px 0;\"><pre>{$result}</pre></div>";
echo "<div style=\"background-color: grey; color: white; padding: 10px; margin: 10px 0;\">

Check failure on line 44 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L44

All output should be run through an escaping function (see the Security sections in the WordPress Developer Handbooks), found '"<div style=\"background-color: grey; color: white; padding: 10px; margin: 10px 0;\"> '.

Check failure on line 44 in src/EduFramework/Core/View/StudooDebugExtension.php

View check run for this annotation

Codacy Production / Codacy Static Code Analysis

src/EduFramework/Core/View/StudooDebugExtension.php#L44

Use of echo language construct is discouraged.
<pre>{$result}</pre>
</div>";
}
}
}

0 comments on commit 10a861b

Please sign in to comment.