Code Coverage |
||||||||||
Lines |
Functions and Methods |
Classes and Traits |
||||||||
| Total | |
81.25% |
13 / 16 |
|
76.92% |
10 / 13 |
CRAP | |
0.00% |
0 / 1 |
| HasRoles | |
81.25% |
13 / 16 |
|
76.92% |
10 / 13 |
14.11 | |
0.00% |
0 / 1 |
| isMaster | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isAdmin | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isStorer | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isSeparator | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isPacker | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isInvoicer | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| isEntrance | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isInspector | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| isRequester | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| hasWarehouseRequesterAccess | |
100.00% |
4 / 4 |
|
100.00% |
1 / 1 |
1 | |||
| belongsToExpedition | |
0.00% |
0 / 1 |
|
0.00% |
0 / 1 |
2 | |||
| belongsToWarehouse | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| belongsToInspection | |
100.00% |
1 / 1 |
|
100.00% |
1 / 1 |
1 | |||
| 1 | <?php |
| 2 | |
| 3 | namespace Domain\User\Traits; |
| 4 | |
| 5 | use Domain\Shared\Enums\SectorEnum; |
| 6 | use Domain\User\Enums\AccessLevel; |
| 7 | |
| 8 | trait HasRoles |
| 9 | { |
| 10 | public function isMaster(): bool |
| 11 | { |
| 12 | return $this->hasAccess(AccessLevel::MASTER->value); |
| 13 | } |
| 14 | |
| 15 | public function isAdmin(): bool |
| 16 | { |
| 17 | return $this->hasAccess(AccessLevel::ADMIN->value); |
| 18 | } |
| 19 | |
| 20 | public function isStorer(): bool |
| 21 | { |
| 22 | return $this->hasAccess(AccessLevel::STORER->value); |
| 23 | } |
| 24 | |
| 25 | public function isSeparator(): bool |
| 26 | { |
| 27 | return $this->hasAccess(AccessLevel::SEPARATOR->value); |
| 28 | } |
| 29 | |
| 30 | public function isPacker(): bool |
| 31 | { |
| 32 | return $this->hasAccess(AccessLevel::PACKER->value); |
| 33 | } |
| 34 | |
| 35 | public function isInvoicer(): bool |
| 36 | { |
| 37 | return $this->hasAccess(AccessLevel::INVOICER->value); |
| 38 | } |
| 39 | |
| 40 | public function isEntrance(): bool |
| 41 | { |
| 42 | return $this->hasAccess(AccessLevel::ENTRANCE->value); |
| 43 | } |
| 44 | |
| 45 | public function isInspector(): bool |
| 46 | { |
| 47 | return $this->hasAccess(AccessLevel::INSPECTOR->value); |
| 48 | } |
| 49 | |
| 50 | public function isRequester(): bool |
| 51 | { |
| 52 | return $this->hasAccess(AccessLevel::REQUESTER->value); |
| 53 | } |
| 54 | |
| 55 | public function hasWarehouseRequesterAccess(): bool |
| 56 | { |
| 57 | return $this->hasAccessLevel( |
| 58 | AccessLevel::REQUESTER->value, |
| 59 | SectorEnum::WAREHOUSE->value |
| 60 | ); |
| 61 | } |
| 62 | |
| 63 | public function belongsToExpedition(): bool |
| 64 | { |
| 65 | return $this->belongsSector(SectorEnum::EXPEDITION); |
| 66 | } |
| 67 | |
| 68 | public function belongsToWarehouse(): bool |
| 69 | { |
| 70 | return $this->belongsSector(SectorEnum::WAREHOUSE); |
| 71 | } |
| 72 | |
| 73 | public function belongsToInspection(): bool |
| 74 | { |
| 75 | return $this->belongsSector(SectorEnum::INSPECTION); |
| 76 | } |
| 77 | } |