1 | <?php |
||
2 | |||
3 | namespace Swaggest\PhpCodeBuilder; |
||
4 | |||
5 | class PhpStdType implements PhpAnyType |
||
6 | { |
||
7 | const TYPE_INT = 'int'; |
||
8 | const TYPE_FLOAT = 'float'; |
||
9 | const TYPE_STRING = 'string'; |
||
10 | const TYPE_BOOL = 'bool'; |
||
11 | const TYPE_MIXED = 'mixed'; |
||
12 | const TYPE_OBJECT = 'object'; |
||
13 | const TYPE_ARRAY = 'array'; |
||
14 | const TYPE_NULL = 'null'; |
||
15 | const TYPE_STATIC = 'static'; |
||
16 | const TYPE_SELF = 'self'; |
||
17 | |||
18 | private $type; |
||
19 | |||
20 | 7 | public function renderArgumentType() |
|
21 | { |
||
22 | 7 | return ''; |
|
23 | } |
||
24 | |||
25 | 10 | public function renderPhpDocType() |
|
26 | { |
||
27 | 10 | return $this->type; |
|
28 | } |
||
29 | |||
30 | 10 | private function __construct($type) |
|
31 | { |
||
32 | 10 | $this->type = $type; |
|
33 | 10 | } |
|
34 | |||
35 | 7 | public static function int() |
|
36 | { |
||
37 | 7 | return new self(self::TYPE_INT); |
|
38 | } |
||
39 | |||
40 | 6 | public static function float() |
|
41 | { |
||
42 | 6 | return new self(self::TYPE_FLOAT); |
|
43 | } |
||
44 | |||
45 | 6 | public static function bool() |
|
46 | { |
||
47 | 6 | return new self(self::TYPE_BOOL); |
|
48 | } |
||
49 | |||
50 | 8 | public static function string() |
|
51 | { |
||
52 | 8 | return new self(self::TYPE_STRING); |
|
53 | } |
||
54 | |||
55 | public static function mixed() |
||
56 | { |
||
57 | static $type = null; |
||
58 | if ($type === null) { |
||
59 | $type = new self(self::TYPE_MIXED); |
||
60 | } |
||
61 | return $type; |
||
62 | } |
||
63 | |||
64 | public static function object() |
||
65 | 4 | { |
|
66 | return new self(self::TYPE_OBJECT); |
||
67 | 4 | } |
|
68 | |||
69 | public static function arr() |
||
70 | 2 | { |
|
71 | return new self(self::TYPE_ARRAY); |
||
72 | 2 | } |
|
73 | |||
74 | public static function null() |
||
75 | { |
||
76 | return new self(self::TYPE_NULL); |
||
77 | } |
||
78 | |||
79 | public static function tStatic() |
||
80 | 4 | { |
|
81 | return new self(self::TYPE_STATIC); |
||
82 | 4 | } |
|
83 | |||
84 | public static function tSelf() |
||
85 | { |
||
86 | return new self(self::TYPE_SELF); |
||
87 | } |
||
88 | |||
89 | } |