GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#154)
by Ross
22:04
created

findAllEntityFqns()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 11
CRAP Score 2

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 15
ccs 11
cts 11
cp 1
crap 2
rs 9.9332
c 0
b 0
f 0
1
<?php declare(strict_types=1);
2
3
namespace EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Action;
4
5
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\Creation\Src\Entity\DataTransferObjects\DtoCreator;
6
use EdmondsCommerce\DoctrineStaticMeta\CodeGeneration\NamespaceHelper;
7
use Symfony\Component\Finder\Finder;
8
9
class CreateDtosForAllEntitiesAction implements ActionInterface
10
{
11
    /**
12
     * @var DtoCreator
13
     */
14
    private $dataTransferObjectCreator;
15
    /**
16
     * @var string
17
     */
18
    private $projectRootNamespace;
19
    /**
20
     * @var string
21
     */
22
    private $projectRootDirectory;
23
    /**
24
     * @var NamespaceHelper
25
     */
26
    private $namespaceHelper;
27
28 4
    public function __construct(DtoCreator $dataTransferObjectCreator, NamespaceHelper $namespaceHelper)
29
    {
30 4
        $this->dataTransferObjectCreator = $dataTransferObjectCreator;
31 4
        $this->namespaceHelper           = $namespaceHelper;
32 4
    }
33
34 4
    public function run(): void
35
    {
36 4
        $entityFqns = $this->findAllEntityFqns();
37 4
        foreach ($entityFqns as $entityFqn) {
38 4
            $this->dataTransferObjectCreator->setNewObjectFqnFromEntityFqn($entityFqn)
39 4
                                            ->createTargetFileObject()
40 4
                                            ->write();
41
        }
42 4
    }
43
44 4
    private function findAllEntityFqns()
45
    {
46 4
        $finder = new Finder();
47 4
        $finder->files()->in($this->projectRootDirectory . '/src/Entities')->name('*.php');
48 4
        $entityFqns = [];
49 4
        foreach ($finder as $splFileInfo) {
50 4
            $path         = $splFileInfo->getRealPath();
51 4
            $subPath      = \substr($path, \strpos($path, '/src/Entities/') + \strlen('/src/Entities/'));
52 4
            $subPath      = \str_replace('.php', '', $subPath);
53 4
            $entityFqns[] = $this->namespaceHelper->tidy(
54 4
                $this->projectRootNamespace . '\\Entities\\' . \str_replace('/', '\\', $subPath)
55
            );
56
        }
57
58 4
        return $entityFqns;
59
    }
60
61 4
    public function setProjectRootNamespace(string $projectRootNamespace): self
62
    {
63 4
        $this->projectRootNamespace = $projectRootNamespace;
64 4
        $this->dataTransferObjectCreator->setProjectRootNamespace($projectRootNamespace);
65
66 4
        return $this;
67
    }
68
69 4
    public function setProjectRootDirectory(string $projectRootDirectory): self
70
    {
71 4
        $this->projectRootDirectory = $projectRootDirectory;
72 4
        $this->dataTransferObjectCreator->setProjectRootDirectory($projectRootDirectory);
73
74 4
        return $this;
75
    }
76
}
77