| Total Complexity | 7 |
| Total Lines | 89 |
| Duplicated Lines | 0 % |
| Coverage | 100% |
| Changes | 2 | ||
| Bugs | 0 | Features | 1 |
| 1 | <?php |
||
| 14 | trait HasFlags |
||
| 15 | { |
||
| 16 | /** |
||
| 17 | * The default flags. |
||
| 18 | * |
||
| 19 | * @var int |
||
| 20 | */ |
||
| 21 | protected static $defaultFlags = NONE; |
||
| 22 | |||
| 23 | /** |
||
| 24 | * The actual flags. |
||
| 25 | * |
||
| 26 | * @var int |
||
| 27 | */ |
||
| 28 | protected $flags; |
||
| 29 | |||
| 30 | /** |
||
| 31 | * Retrieve the default flags |
||
| 32 | * |
||
| 33 | * @return int |
||
| 34 | */ |
||
| 35 | 246 | public static function getDefaultFlags(): int |
|
| 38 | } |
||
| 39 | |||
| 40 | /** |
||
| 41 | * Retrieve the DTO flags |
||
| 42 | * |
||
| 43 | * @return int |
||
| 44 | */ |
||
| 45 | 243 | public function getFlags(): int |
|
| 48 | } |
||
| 49 | |||
| 50 | /** |
||
| 51 | * Determine whether the DTO flags include the given flags |
||
| 52 | * |
||
| 53 | * @param int $flags |
||
| 54 | * @return bool |
||
| 55 | */ |
||
| 56 | 3 | public function hasFlags(int $flags): bool |
|
| 59 | } |
||
| 60 | |||
| 61 | /** |
||
| 62 | * Set the DTO flags |
||
| 63 | * |
||
| 64 | * @param int $flags |
||
| 65 | * @return Dto |
||
| 66 | */ |
||
| 67 | 18 | public function setFlags(int $flags): Dto |
|
| 68 | { |
||
| 69 | 18 | if (!($this->getFlags() & MUTABLE)) { |
|
| 70 | 9 | return static::make($this->toArray(), $flags); |
|
| 71 | } |
||
| 72 | |||
| 73 | 9 | $this->flags = $flags; |
|
| 74 | |||
| 75 | 9 | return $this; |
|
| 76 | } |
||
| 77 | |||
| 78 | /** |
||
| 79 | * Add the given flags to the DTO flags |
||
| 80 | * |
||
| 81 | * @param int $flags |
||
| 82 | * @return Dto |
||
| 83 | */ |
||
| 84 | 6 | public function addFlags(int $flags): Dto |
|
| 89 | } |
||
| 90 | |||
| 91 | /** |
||
| 92 | * Remove the given flags from the DTO flags |
||
| 93 | * |
||
| 94 | * @param int $flags |
||
| 95 | * @return Dto |
||
| 96 | */ |
||
| 97 | 6 | public function removeFlags(int $flags): Dto |
|
| 103 | } |
||
| 104 | } |
||
| 105 |