FileExample::demonstrate()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 47

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 47
rs 9.1563
c 0
b 0
f 0
cc 1
nc 1
nop 0
1
#!/bin/php
2
<?php
3
/**
4
 * @author stev leibelt <[email protected]>
5
 * @since 2014-07-11 
6
 */
7
8
require_once 'AbstractExample.php';
9
require_once __DIR__ . '/../vendor/autoload.php';
10
11
/**
12
 * Class FileExample
13
 */
14
class FileExample extends AbstractExample
15
{
16
    /**
17
     * @return mixed
18
     */
19
    function demonstrate()
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
20
    {
21
        //----begin of factories
22
        $classFactory           = $this->getClassGeneratorFactory();
23
        $constantFactory        = $this->getConstantGeneratorFactory();
24
        $documentationFactory   = $this->getDocumentationGeneratorFactory();
25
        $fileFactory            = $this->getFileGeneratorFactory();
26
        $methodFactory          = $this->getMethodGeneratorFactory();
27
        //----end of factories
28
29
        //----begin of generators
30
        $class          = $classFactory->create();
31
        $constant       = $constantFactory->create();
32
        $fileGenerator  = $fileFactory->create();
33
        $method         = $methodFactory->create();
34
        //----end of generators
35
36
        //----begin content creation
37
        $class->setDocumentation($documentationFactory->create());
38
        $class->setName('MyClass');
39
        $class->setNamespace('MyClassNamespace');
40
41
        $constant->setName('MY_CONSTANT');
42
        $constant->setValue('123');
43
44
        $content = 'echo \'hello world\' . PHP_EOL;';
45
46
        $fileGenerator->setDocumentation($documentationFactory->create());
47
48
        $method->setDocumentation($documentationFactory->create());
49
        $method->setName('myMethod');
50
        //----end content creation
51
52
        //----begin of file generation
53
        $fileGenerator->markAsExecutable();
54
        $fileGenerator->addClass($class);
55
        $fileGenerator->addConstant($constant);
56
        $fileGenerator->addFileContent($content);
57
        $fileGenerator->addMethod($method);
58
        //----end of file generation
59
60
        //----begin of output
61
        echo 'generated content' . PHP_EOL;
62
        echo '----' . PHP_EOL;
63
        echo $fileGenerator->generate() . PHP_EOL;
64
        //----end of output
65
    }
66
}
67
68
$example = new FileExample();
69
$example->demonstrate();