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.

AsyncClassGenerator   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 48
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 10

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 48
ccs 24
cts 24
cp 1
rs 10
c 0
b 0
f 0
wmc 2
lcom 1
cbo 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 40 2
1
<?php declare(strict_types=1);
2
3
namespace ApiClients\Tools\ResourceGenerator\FileGenerators;
4
5
use ApiClients\Tools\ResourceGenerator\FileGeneratorInterface;
6
use PhpParser\BuilderFactory;
7
use PhpParser\Node;
8
9
final class AsyncClassGenerator extends AbstractExtendingClassGenerator implements FileGeneratorInterface
10
{
11
    const NAMESPACE = 'Async';
12
13
    /**
14
     * @return Node
15
     */
16 1
    public function generate(): Node
17
    {
18 1
        $classChunks = explode('\\', $this->yaml['class']);
19 1
        $className = array_pop($classChunks);
20
        $namespace = $this->yaml['src']['namespace'] . '\\' . static::NAMESPACE;
21 1
        if (count($classChunks) > 0) {
22 1
            $namespace .= '\\' . implode('\\', $classChunks);
23 1
            $namespace = str_replace('\\\\', '\\', $namespace);
24
        }
25 1
        $baseClass = $this->yaml['src']['namespace'] . '\\' . $this->yaml['class'];
26
27 1
        $factory = new BuilderFactory();
28
29 1
        $class = $factory->class($className)
30 1
            ->extend('Base' . $className);
31
32 1
        $class->addStmt(
33 1
            $factory->method('refresh')
34 1
                ->makePublic()
35 1
                ->setReturnType($className)
36 1
                ->addStmt(
37 1
                    new Node\Stmt\Throw_(
38 1
                        new Node\Expr\New_(
39 1
                            new Node\Name('\Exception'),
40
                            [
41 1
                                new Node\Scalar\String_(
42 1
                                    'TODO: create refresh method!'
43
                                ),
44
                            ]
45
                        )
46
                    )
47
                )
48
        );
49
50 1
        return $factory->namespace($namespace)
51 1
            ->addStmt($factory->use($baseClass)->as('Base' . $className))
52 1
            ->addStmt($class)
53 1
            ->getNode()
54
            ;
55
    }
56
}
57