Completed
Push — master ( 36c459...78506e )
by Guillaume
02:39
created

EntiteGenerator::getFichiers()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 12
Code Lines 9

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 12
c 0
b 0
f 0
rs 9.4285
cc 1
eloc 9
nc 1
nop 0
1
<?php
2
3
namespace Starkerxp\StructureBundle\Generator;
4
5
use Symfony\Component\HttpKernel\Bundle\Bundle;
6
7
class EntiteGenerator extends AbstractGenerator
8
{
9 View Code Duplication
    public function generate(Bundle $bundle, $libelle)
0 ignored issues
show
Duplication introduced by
This method seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
10
    {
11
        $parameters = $this->getParamaters($bundle, $libelle);
12
        $parameters['nomService'] = strtolower(
13
            str_replace(['_Bundle', '@'], '', preg_replace('#\B([A-Z])#', '_\1', $parameters['namespaceBundle']))
14
        );
15
        foreach ($this->getFichiers() as $fichier) {
16
            try {
17
                $this->kernel->locateResource("@StarkerxpStructureBundle/Resources/views/Gabarit/".$fichier.".twig");
18
            } catch (\InvalidArgumentException $e) {
19
                throw new \InvalidArgumentException('Il manque un fichier de template');
20
            }
21
            $target = $bundle->getPath().str_replace($this->getClef(), [$libelle, lcfirst($libelle)], $fichier);
22
            $this->traiterLeFichier($fichier, $target, $parameters);
23
        }
24
    }
25
26
27
    public function getParamaters(Bundle $bundle, $libelle)
28
    {
29
        return array(
30
            'nomEntity' => $libelle,
31
            'namespace' => $bundle->getNamespace(),
32
            'namespaceBundle' => '@'.$bundle->getName(),
33
            'namespaceFQC' => str_replace('\\', '\\\\', $bundle->getNamespace()),
34
        );
35
    }
36
37
    public function getClef()
38
    {
39
        return ['_nomEntity_', '_lnomEntity_'];
40
    }
41
42
    public function getFichiers()
43
    {
44
        return [
45
            '/Resources/config/managers.yml',
46
            '/Entity/_nomEntity_.php',
47
            '/Manager/_nomEntity_Manager.php',
48
            '/Repository/_nomEntity_Repository.php',
49
            '/Tests/Manager/_nomEntity_ManagerTest.php',
50
            '/Tests/DataFixtures/_nomEntity_Manager/_nomEntity_Manager.yml',
51
            '/Tests/DataFixtures/_nomEntity_Manager/Default_nomEntity_.yml',
52
        ];
53
    }
54
}
0 ignored issues
show
Coding Style introduced by
As per coding style, files should not end with a newline character.

This check marks files that end in a newline character, i.e. an empy line.

Loading history...
55