1
|
|
|
<?php |
2
|
|
|
|
3
|
|
|
/** |
4
|
|
|
* This file is part of PhpUnitGen. |
5
|
|
|
* |
6
|
|
|
* (c) 2017-2018 Paul Thébaud <[email protected]> |
7
|
|
|
* |
8
|
|
|
* For the full copyright and license information, please view the LICENSE.md |
9
|
|
|
* file that was distributed with this source code. |
10
|
|
|
*/ |
11
|
|
|
|
12
|
|
|
namespace PhpUnitGen\Model\PropertyTrait; |
13
|
|
|
|
14
|
|
|
use PhpUnitGen\Model\PropertyInterface\TypeInterface; |
15
|
|
|
|
16
|
|
|
/** |
17
|
|
|
* Trait TypeTrait. |
18
|
|
|
* |
19
|
|
|
* @author Paul Thébaud <[email protected]>. |
20
|
|
|
* @copyright 2017-2018 Paul Thébaud <[email protected]>. |
21
|
|
|
* @license https://opensource.org/licenses/MIT The MIT license. |
22
|
|
|
* @link https://github.com/paul-thebaud/phpunit-generator |
23
|
|
|
* @since Class available since Release 2.0.0. |
24
|
|
|
*/ |
25
|
|
|
trait TypeTrait |
26
|
|
|
{ |
27
|
|
|
/** |
28
|
|
|
* @var int|null $type The type as an integer constant. |
29
|
|
|
*/ |
30
|
|
|
protected $type = TypeInterface::MIXED; |
31
|
|
|
|
32
|
|
|
/** |
33
|
|
|
* @var bool $nullable A boolean describing if it is nullable. |
34
|
|
|
*/ |
35
|
|
|
protected $nullable = false; |
36
|
|
|
|
37
|
|
|
/** |
38
|
|
|
* @var string|null $customType A custom type as a string (not null if the type is CUSTOM). |
39
|
|
|
*/ |
40
|
|
|
protected $customType = null; |
41
|
|
|
|
42
|
|
|
/** |
43
|
|
|
* @param int|null $type The new type to set. |
44
|
|
|
*/ |
45
|
|
|
public function setType(?int $type): void |
46
|
|
|
{ |
47
|
|
|
$this->type = $type; |
48
|
|
|
} |
49
|
|
|
|
50
|
|
|
/** |
51
|
|
|
* @return int|null The current type. |
52
|
|
|
*/ |
53
|
|
|
public function getType(): ?int |
54
|
|
|
{ |
55
|
|
|
return $this->type; |
56
|
|
|
} |
57
|
|
|
|
58
|
|
|
/** |
59
|
|
|
* @param bool $nullable The new nullable value to set. |
60
|
|
|
*/ |
61
|
|
|
public function setNullable(bool $nullable): void |
62
|
|
|
{ |
63
|
|
|
$this->nullable = $nullable; |
64
|
|
|
} |
65
|
|
|
|
66
|
|
|
/** |
67
|
|
|
* @return bool True if it is nullable. |
68
|
|
|
*/ |
69
|
|
|
public function nullable(): bool |
70
|
|
|
{ |
71
|
|
|
return $this->nullable; |
72
|
|
|
} |
73
|
|
|
|
74
|
|
|
/** |
75
|
|
|
* @param string|null $customType The new custom type to set as a string. |
76
|
|
|
*/ |
77
|
|
|
public function setCustomType(?string $customType): void |
78
|
|
|
{ |
79
|
|
|
$this->customType = $customType; |
80
|
|
|
} |
81
|
|
|
|
82
|
|
|
/** |
83
|
|
|
* @return string|null The current custom type as a string. |
84
|
|
|
*/ |
85
|
|
|
public function getCustomType(): ?string |
86
|
|
|
{ |
87
|
|
|
return $this->customType; |
88
|
|
|
} |
89
|
|
|
} |
90
|
|
|
|