Passed
Push — master ( 540337...9ab9ce )
by Bruno
05:48
created

directives()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 15
c 1
b 0
f 0
nc 2
nop 0
dl 0
loc 22
rs 9.7666
1
<?php declare(strict_types=1);
2
3
require(__DIR__ . '/../vendor/autoload.php');
4
5
use Formularium\Factory\DatatypeFactory;
0 ignored issues
show
Bug introduced by
The type Formularium\Factory\DatatypeFactory was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
6
use Formularium\Formularium;
7
use Modelarium\Laravel\Processor as LaravelProcessor;
8
9
function datatypes()
10
{
11
    $markdown = DatatypeFactory::map(
12
        function (\ReflectionClass $reflection): array {
13
            $class = $reflection->getName();
14
    
15
            /**
16
             * @var Datatype $d
17
             */
18
            $d = new $class(); // TODO: factory would be better
19
            return [
20
                'name' => $class,
21
                'value' => $d->getMetadata()->toMarkdown()
22
            ];
23
        }
24
    );
25
26
    ksort($markdown);
27
28
    $datatypeAPI = '
29
# Datatypes
30
31
List of validators and its parameters generated automatically.
32
33
' . join("\n", $markdown);
34
35
    file_put_contents(__DIR__ . '/../docs/api-datatypes.md', $datatypeAPI);
36
}
37
38
function directives()
39
{
40
    $directiveMD = <<<EOF
41
# Directives\n\n
42
43
Directives supported by Modelarium.
44
45
EOF;
46
    $directives = LaravelProcessor::getDirectivesGraphql();
47
    foreach ($directives as $name => $directive) {
48
        $directiveMD .= <<<EOF
49
50
## @$name
51
52
```graphql
53
$directive
54
```
55
56
EOF;
57
    }
58
    $filename = __DIR__ . '/../docs/api-directives.md';
59
    \Safe\file_put_contents($filename, $directiveMD);
60
}
61
62
datatypes();
63
directives();
64
echo "Generated.\n";
65