Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
CRAP | |
0.00% |
0 / 1 |
| SenderEntity | |
0.00% |
0 / 6 |
|
0.00% |
0 / 6 |
42 | |
0.00% |
0 / 1 |
| isActive | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isDefault | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getValue | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| getChannel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isValidForChannel | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| toArray | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace App\Modules\ContactModule\Entities; |
| 4 | |
| 5 | use CodeIgniter\Entity\Entity; |
| 6 | |
| 7 | class SenderEntity extends Entity |
| 8 | { |
| 9 | protected $attributes = [ |
| 10 | 'id' => null, |
| 11 | 'name' => null, |
| 12 | 'channel' => null, |
| 13 | 'provider_id' => null, |
| 14 | 'value' => null, |
| 15 | 'status' => 1, |
| 16 | 'is_default' => 0, |
| 17 | 'provider_name' => null, |
| 18 | ]; |
| 19 | |
| 20 | protected $casts = [ |
| 21 | 'id' => 'integer', |
| 22 | 'provider_id' => 'integer', |
| 23 | 'status' => 'boolean', |
| 24 | 'is_default' => 'boolean', |
| 25 | ]; |
| 26 | |
| 27 | public function isActive(): bool |
| 28 | { |
| 29 | return (bool) $this->status; |
| 30 | } |
| 31 | |
| 32 | public function isDefault(): bool |
| 33 | { |
| 34 | return (bool) $this->is_default; |
| 35 | } |
| 36 | |
| 37 | public function getValue(): ?string |
| 38 | { |
| 39 | return $this->value ?? null; |
| 40 | } |
| 41 | |
| 42 | public function getChannel(): ?string |
| 43 | { |
| 44 | return strtolower($this->channel ?? ''); |
| 45 | } |
| 46 | |
| 47 | public function isValidForChannel(string $channel): bool |
| 48 | { |
| 49 | return strtolower($this->getChannel()) === strtolower($channel); |
| 50 | } |
| 51 | |
| 52 | /** |
| 53 | * IMPORTANT: signature compatible CI4 |
| 54 | */ |
| 55 | public function toArray( |
| 56 | bool $onlyChanged = false, |
| 57 | bool $cast = true, |
| 58 | bool $recursive = false |
| 59 | ): array { |
| 60 | return parent::toArray($onlyChanged, $cast, $recursive); |
| 61 | } |
| 62 | } |