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 (#199)
by joseph
21:04
created

findAllEntityFqns()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 15
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 10
nc 2
nop 0
dl 0
loc 15
ccs 0
cts 14
cp 0
crap 6
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
    public function __construct(DtoCreator $dataTransferObjectCreator, NamespaceHelper $namespaceHelper)
29
    {
30
        $this->dataTransferObjectCreator = $dataTransferObjectCreator;
31
        $this->namespaceHelper           = $namespaceHelper;
32
    }
33
34
    public function run(): void
35
    {
36
        $entityFqns = $this->findAllEntityFqns();
37
        foreach ($entityFqns as $entityFqn) {
38
            $this->dataTransferObjectCreator->setNewObjectFqnFromEntityFqn($entityFqn)
39
                                            ->createTargetFileObject()
40
                                            ->write();
41
        }
42
    }
43
44
    private function findAllEntityFqns()
45
    {
46
        $finder = new Finder();
47
        $finder->files()->in($this->projectRootDirectory . '/src/Entities')->name('*.php');
48
        $entityFqns = [];
49
        foreach ($finder as $splFileInfo) {
50
            $path         = $splFileInfo->getRealPath();
51
            $subPath      = \substr($path, \strpos($path, '/src/Entities/') + \strlen('/src/Entities/'));
52
            $subPath      = \str_replace('.php', '', $subPath);
53
            $entityFqns[] = $this->namespaceHelper->tidy(
54
                $this->projectRootNamespace . '\\Entities\\' . \str_replace('/', '\\', $subPath)
55
            );
56
        }
57
58
        return $entityFqns;
59
    }
60
61
    public function setProjectRootNamespace(string $projectRootNamespace): self
62
    {
63
        $this->projectRootNamespace = $projectRootNamespace;
64
        $this->dataTransferObjectCreator->setProjectRootNamespace($projectRootNamespace);
65
66
        return $this;
67
    }
68
69
    public function setProjectRootDirectory(string $projectRootDirectory): self
70
    {
71
        $this->projectRootDirectory = $projectRootDirectory;
72
        $this->dataTransferObjectCreator->setProjectRootDirectory($projectRootDirectory);
73
74
        return $this;
75
    }
76
}
77