ClientAbstract::methods()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 14

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 14
dl 0
loc 17
c 1
b 0
f 0
rs 9.7998
cc 2
nc 2
nop 0
1
<?php
2
3
namespace carono\turbotext\codegen;
4
5
use carono\codegen\ClassGenerator;
6
7
class ClientAbstract extends ClassGenerator
8
{
9
    protected function formExtends()
10
    {
11
        return 'carono\rest\Client';
12
    }
13
14
    protected function formClassName()
15
    {
16
        return 'ClientAbstract';
17
    }
18
19
    protected function formClassNamespace()
20
    {
21
        return 'carono\turbotext';
22
    }
23
24
    protected function formOutputPath()
25
    {
26
        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
27
    }
28
29
    public function methods()
30
    {
31
        $this->phpClass->setAbstract(true);
32
        foreach ($this->params as $section) {
33
            $sectionRequest = new RequestAbstract();
34
            $sectionRequest->renderToFile($section);
35
            $className = "\\" . $sectionRequest->formClassNamespace() . "\\" . $sectionRequest->formClassName();
36
            $method = $this->phpClass->addMethod($section['name']);
37
            $body = <<<PHP
38
return (new $className(\$this));
39
PHP;
40
            $method->addBody($body);
41
            $method->addComment($section['description']);
42
            $method->addComment('');
43
            $method->addComment("@return $className");
44
        }
45
        return false;
46
    }
47
}