ResponseAbstract::formClassNamespace()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace carono\etxtru\codegen;
4
5
use carono\codegen\ClassGenerator;
6
7
class ResponseAbstract extends ClassGenerator
8
{
9
    public $properties = [];
10
11
    protected function formExtends()
12
    {
13
        if (strpos($this->formClassName(), 'ElementResponse')) {
14
            return 'carono\etxtru\ArrayObject';
15
        }
16
17
        return 'carono\etxtru\ResponseAbstract';
18
    }
19
20
    protected function formClassName()
21
    {
22
        $name = $this->params['name'];
23
24
25
        $name = formClassName($name);
26
        if (!isset($this->params['returns']) && substr($name, -1, 1) == 's') {
27
            $name = substr($name, 0, -1) . 'Element';
28
        }
29
        return $name . 'Response';
30
    }
31
32
    protected function formClassNamespace()
33
    {
34
        return 'carono\etxtru\response';
35
    }
36
37
    protected function formOutputPath()
38
    {
39
        return dirname(__DIR__) . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'response' . DIRECTORY_SEPARATOR . $this->formClassName() . '.php';
40
    }
41
42
    protected function classProperties()
43
    {
44
        $properties = [];
45
        foreach ($this->params['returns'] as $param) {
46
            $properties[$param['name']] = [
47
                'comment' => [
48
                    stripAndWordWrap($param['description'])
49
                ],
50
                'value' => null
51
            ];
52
        }
53
        return $properties;
54
    }
55
56
}