Skip to content

Commit 82e6340

Browse files
author
Jean-David LABAILS
committed
cs symfony2 std
1 parent f5d4639 commit 82e6340

36 files changed

+2044
-207
lines changed

Command/InitCommand.php

Lines changed: 18 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,17 @@
33
namespace JD\PhpProjectAnalyzerBundle\Command;
44

55
use Symfony\Bundle\FrameworkBundle\Command\ContainerAwareCommand;
6-
use Symfony\Component\Console\Input\InputArgument;
76
use Symfony\Component\Console\Input\InputInterface;
8-
use Symfony\Component\Console\Input\InputOption;
97
use Symfony\Component\Console\Output\OutputInterface;
10-
use Symfony\Component\Console\Helper\DialogHelper;
118

9+
/**
10+
* Command d'initialisation des repertoires de rapports d'analyses
11+
*/
1212
class InitCommand extends ContainerAwareCommand
1313
{
14+
/**
15+
* Configuration de la commande
16+
*/
1417
protected function configure()
1518
{
1619
$this
@@ -19,6 +22,12 @@ protected function configure()
1922
;
2023
}
2124

25+
/**
26+
* Execution de la commande
27+
* @param InputInterface $input
28+
* @param OutputInterface $output
29+
* @return type
30+
*/
2231
protected function execute(InputInterface $input, OutputInterface $output)
2332
{
2433
$param = $this->getContainer()->getParameter('jd.ppa.global');
@@ -28,23 +37,24 @@ protected function execute(InputInterface $input, OutputInterface $output)
2837
chmod($installerPath, 0755);
2938
if (!is_executable($installerPath)) {
3039
$output->writeln(basename($installerPath).' non executable');
40+
3141
return;
3242
}
3343
}
34-
44+
3545
$dialog = $this->getHelperSet()->get('dialog');
36-
46+
3747
$webServer = $dialog->ask(
3848
$output,
3949
'Please enter your web server user [www-data:www-data] :',
4050
'www-data:www-data'
4151
);
42-
52+
4353
$res = '';
4454
exec(__DIR__.'/../Resources/sh/install.sh '.$webServer.' '.$param['reportPath'], $res);
4555

46-
$res []= "\nInstallation done";
47-
56+
$res[] = "\nInstallation done";
57+
4858
$output->writeln($res);
4959
}
5060
}

Controller/MainController.php

Lines changed: 22 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4,25 +4,29 @@
44

55
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
66

7+
/**
8+
* Controller de l'interface principale
9+
*/
710
class MainController extends Controller
811
{
12+
/**
13+
* Index
14+
* @return type
15+
*/
916
public function indexAction()
1017
{
11-
//var_dump($this->getParameter('jd.ppa.global'));
12-
//$this->get('jd_php_project_analyzer')->get('title');
13-
1418
$projectAnalyser = $this->get('jd_ppa.projectAnalyser');
15-
$_testInfo = $projectAnalyser->exploitTestReport();
19+
$testInfo = $projectAnalyser->exploitTestReport();
1620

17-
$tabAvailableAnalysis = array(
21+
$tabAvailableAnalysis = [
1822
'test' => 'Tests fonctionnels et unitaires',
1923
'md' => 'PhpMD : Mess Detector',
2024
'cpd' => 'CPD : Copy-Paste Detector',
2125
'cs' => 'CS : Code Sniffer',
2226
'loc' => 'PhpLoc : Statistic',
2327
'docs' => 'PhpDoc : Documentation',
24-
'depend' => 'PhpDepend : Métriques d\'analyse'
25-
);
28+
'depend' => 'PhpDepend : Métriques d\'analyse',
29+
];
2630

2731
return $this->render('JDPhpProjectAnalyzerBundle:Main:index.html.twig', [
2832
'tabAvailableAnalysis' => $tabAvailableAnalysis,
@@ -31,23 +35,31 @@ public function indexAction()
3135
'isAnalyzeInProgress' => $projectAnalyser->isAnalyzeInProgress(),
3236
'a' => $projectAnalyser->getAnalyze(),
3337
'_quality_info' => $projectAnalyser->getQualityInfo(),
34-
'_testInfo' => $_testInfo,
38+
'_testInfo' => $testInfo,
3539
'_reportInfo' => $projectAnalyser->getReportInfo(),
36-
'_note' => $projectAnalyser->getNote($_testInfo)
40+
'_note' => $projectAnalyser->getNote($testInfo),
3741
]);
3842
}
3943

44+
/**
45+
* Display phpinfo
46+
* @return type
47+
*/
4048
public function phpinfoAction()
4149
{
4250
return $this->render('JDPhpProjectAnalyzerBundle:Main:res.html.twig', ['res' => phpinfo()]);
4351
}
4452

53+
/**
54+
* Launch analysis
55+
* @return type
56+
*/
4557
public function analyzeAction()
4658
{
4759
$scriptManager = $this->get('jd_ppa.scriptManager');
4860

4961
return $this->render('JDPhpProjectAnalyzerBundle:Main:res.html.twig', [
50-
'res' => $scriptManager->lancerAnalyse()
62+
'res' => $scriptManager->lancerAnalyse(),
5163
]);
5264
}
5365
}

DependencyInjection/JDPhpProjectAnalyzerExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,11 +24,11 @@ public function load(array $configs, ContainerBuilder $container)
2424

2525
$loader = new Loader\YamlFileLoader($container, new FileLocator(__DIR__.'/../Resources/config'));
2626
$loader->load('services.yml');
27-
27+
2828
$this->addConfigToParameter('jd.ppa', $config, $container);
2929
$container->setParameter('jd.ppa.global', $config);
3030
}
31-
31+
3232
private function addConfigToParameter($prefix, array $config, ContainerBuilder $container)
3333
{
3434
foreach ($config as $k => $v) {

Entities/Analyze.php

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -320,11 +320,10 @@ public function getExecTime()
320320
public function getReadableExecTime()
321321
{
322322
if ($this->execTime > 120) {
323-
$res = round($this->execTime / 60, 0, PHP_ROUND_HALF_DOWN) . ' min '. ($this->execTime%60).' sec ';
324-
} else {
325-
$res = $this->execTime.' sec';
323+
return round($this->execTime / 60, 0, PHP_ROUND_HALF_DOWN).' min '.($this->execTime%60).' sec ';
326324
}
327-
return $res;
325+
326+
return $this->execTime.' sec';
328327
}
329328

330329
/**
@@ -335,7 +334,7 @@ public function getReadableExecTime()
335334
*/
336335
public function setNbBundles($nbBundles)
337336
{
338-
$this->nbBundles = (int)$nbBundles;
337+
$this->nbBundles = (int) $nbBundles;
339338

340339
return $this;
341340
}
@@ -358,7 +357,7 @@ public function getNbBundles()
358357
*/
359358
public function setNbDir($nbDir)
360359
{
361-
$this->nbDir = (int)$nbDir;
360+
$this->nbDir = (int) $nbDir;
362361

363362
return $this;
364363
}
@@ -381,7 +380,7 @@ public function getNbDir()
381380
*/
382381
public function setNbFile($nbFile)
383382
{
384-
$this->nbFile = (int)$nbFile;
383+
$this->nbFile = (int) $nbFile;
385384

386385
return $this;
387386
}
@@ -404,7 +403,7 @@ public function getNbFile()
404403
*/
405404
public function setNbPhpFile($nbPhpFile)
406405
{
407-
$this->nbPhpFile = (int)$nbPhpFile;
406+
$this->nbPhpFile = (int) $nbPhpFile;
408407

409408
return $this;
410409
}
@@ -427,7 +426,7 @@ public function getNbPhpFile()
427426
*/
428427
public function setNbCSSFile($nbCSSFile)
429428
{
430-
$this->nbCSSFile = (int)$nbCSSFile;
429+
$this->nbCSSFile = (int) $nbCSSFile;
431430

432431
return $this;
433432
}
@@ -450,7 +449,7 @@ public function getNbCSSFile()
450449
*/
451450
public function setNbCSSLib($nbCSSLib)
452451
{
453-
$this->nbCSSLib = (int)$nbCSSLib;
452+
$this->nbCSSLib = (int) $nbCSSLib;
454453

455454
return $this;
456455
}
@@ -473,7 +472,7 @@ public function getNbCSSLib()
473472
*/
474473
public function setNbJSFile($nbJSFile)
475474
{
476-
$this->nbJSFile = (int)$nbJSFile;
475+
$this->nbJSFile = (int) $nbJSFile;
477476

478477
return $this;
479478
}
@@ -496,7 +495,7 @@ public function getNbJSFile()
496495
*/
497496
public function setNbJSLib($nbJSLib)
498497
{
499-
$this->nbJSLib = (int)$nbJSLib;
498+
$this->nbJSLib = (int) $nbJSLib;
500499

501500
return $this;
502501
}
@@ -519,7 +518,7 @@ public function getNbJSLib()
519518
*/
520519
public function setNbTwig($nbTwig)
521520
{
522-
$this->nbTwig = (int)$nbTwig;
521+
$this->nbTwig = (int) $nbTwig;
523522

524523
return $this;
525524
}
@@ -542,7 +541,7 @@ public function getNbTwig()
542541
*/
543542
public function setNbNamespace($nbNamespace)
544543
{
545-
$this->nbNamespace = (int)$nbNamespace;
544+
$this->nbNamespace = (int) $nbNamespace;
546545

547546
return $this;
548547
}
@@ -565,7 +564,7 @@ public function getNbNamespace()
565564
*/
566565
public function setNbClasses($nbClasses)
567566
{
568-
$this->nbClasses = (int)$nbClasses;
567+
$this->nbClasses = (int) $nbClasses;
569568

570569
return $this;
571570
}
@@ -588,7 +587,7 @@ public function getNbClasses()
588587
*/
589588
public function setNbMethod($nbMethod)
590589
{
591-
$this->nbMethod = (int)$nbMethod;
590+
$this->nbMethod = (int) $nbMethod;
592591

593592
return $this;
594593
}
@@ -626,11 +625,19 @@ public function getLangue()
626625
return $this->langue;
627626
}
628627

628+
/**
629+
* Serialize this
630+
* @return type
631+
*/
629632
public function jsonSerialize()
630633
{
631634
return get_object_vars($this);
632635
}
633636

637+
/**
638+
* Set an Analyse object from an array
639+
* @param type $data
640+
*/
634641
public function setFromArray($data)
635642
{
636643
foreach ($data as $key => $value) {

JDPhpProjectAnalyzerBundle.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,9 @@
44

55
use Symfony\Component\HttpKernel\Bundle\Bundle;
66

7+
/**
8+
* Bundle class
9+
*/
710
class JDPhpProjectAnalyzerBundle extends Bundle
811
{
912
}

0 commit comments

Comments
 (0)