Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
87.50% |
7 / 8 |
|
75.00% |
3 / 4 |
CRAP | |
0.00% |
0 / 1 |
| CostCenter | |
87.50% |
7 / 8 |
|
75.00% |
3 / 4 |
4.03 | |
0.00% |
0 / 1 |
| __construct | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| getId | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
100.00% |
5 / 5 |
|
100.00% |
1 / 1 |
1 | |||
| jsonSerialize | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | /** |
| 3 | * Jingga |
| 4 | * |
| 5 | * PHP Version 8.1 |
| 6 | * |
| 7 | * @package Modules\Accounting\Models |
| 8 | * @copyright Dennis Eichhorn |
| 9 | * @license OMS License 2.0 |
| 10 | * @version 1.0.0 |
| 11 | * @link https://jingga.app |
| 12 | */ |
| 13 | declare(strict_types=1); |
| 14 | |
| 15 | namespace Modules\Accounting\Models; |
| 16 | |
| 17 | /** |
| 18 | * Cost center class. |
| 19 | * |
| 20 | * @package Modules\Accounting\Models |
| 21 | * @license OMS License 2.0 |
| 22 | * @link https://jingga.app |
| 23 | * @since 1.0.0 |
| 24 | */ |
| 25 | class CostCenter |
| 26 | { |
| 27 | /** |
| 28 | * ID. |
| 29 | * |
| 30 | * @var int |
| 31 | * @since 1.0.0 |
| 32 | */ |
| 33 | public int $id = 0; |
| 34 | |
| 35 | /** |
| 36 | * Code. |
| 37 | * |
| 38 | * @var string |
| 39 | * @since 1.0.0 |
| 40 | */ |
| 41 | public string $code = ''; |
| 42 | |
| 43 | /** |
| 44 | * Localization. |
| 45 | * |
| 46 | * @var CostCenterL11n |
| 47 | * @since 1.0.0 |
| 48 | */ |
| 49 | public CostCenterL11n $l11n; |
| 50 | |
| 51 | /** |
| 52 | * Parent. |
| 53 | * |
| 54 | * @var null|int|CostCenter |
| 55 | * @since 1.0.0 |
| 56 | */ |
| 57 | public $parent = null; |
| 58 | |
| 59 | /** |
| 60 | * Constructor. |
| 61 | * |
| 62 | * @since 1.0.0 |
| 63 | */ |
| 64 | public function __construct() |
| 65 | { |
| 66 | $this->l11n = new CostCenterL11n(); |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Get balance id |
| 71 | * |
| 72 | * @return int |
| 73 | * |
| 74 | * @since 1.0.0 |
| 75 | */ |
| 76 | public function getId() : int |
| 77 | { |
| 78 | return $this->id; |
| 79 | } |
| 80 | |
| 81 | /** |
| 82 | * {@inheritdoc} |
| 83 | */ |
| 84 | public function toArray() : array |
| 85 | { |
| 86 | return [ |
| 87 | 'id' => $this->id, |
| 88 | 'code' => $this->code, |
| 89 | 'parent' => $this->parent, |
| 90 | ]; |
| 91 | } |
| 92 | |
| 93 | /** |
| 94 | * {@inheritdoc} |
| 95 | */ |
| 96 | public function jsonSerialize() : mixed |
| 97 | { |
| 98 | return $this->toArray(); |
| 99 | } |
| 100 | } |