bristol-su /
control
| 1 | <?php |
||
| 2 | |||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||
| 3 | namespace BristolSU\ControlDB\Cache; |
||
| 4 | |||
| 5 | use BristolSU\ControlDB\Contracts\Models\Role as RoleModel; |
||
| 6 | use BristolSU\ControlDB\Contracts\Repositories\Role as RoleRepositoryContract; |
||
| 7 | use Illuminate\Contracts\Cache\Repository; |
||
| 8 | use Illuminate\Support\Collection; |
||
| 9 | |||
| 10 | class Role implements RoleRepositoryContract |
||
|
0 ignored issues
–
show
|
|||
| 11 | { |
||
| 12 | |||
| 13 | /** |
||
|
0 ignored issues
–
show
|
|||
| 14 | * @var RoleRepositoryContract |
||
| 15 | */ |
||
| 16 | private $roleRepository; |
||
|
0 ignored issues
–
show
|
|||
| 17 | /** |
||
|
0 ignored issues
–
show
|
|||
| 18 | * @var Repository |
||
| 19 | */ |
||
| 20 | private $cache; |
||
|
0 ignored issues
–
show
|
|||
| 21 | |||
| 22 | 58 | public function __construct(RoleRepositoryContract $roleRepository, Repository $cache) |
|
|
0 ignored issues
–
show
|
|||
| 23 | { |
||
| 24 | 58 | $this->roleRepository = $roleRepository; |
|
| 25 | 58 | $this->cache = $cache; |
|
| 26 | 58 | } |
|
| 27 | |||
| 28 | /** |
||
|
0 ignored issues
–
show
|
|||
| 29 | * @inheritDoc |
||
| 30 | */ |
||
|
0 ignored issues
–
show
|
|||
| 31 | 23 | public function getById(int $id): RoleModel |
|
| 32 | { |
||
| 33 | return $this->cache->rememberForever(static::class . '@getById:' . $id, function() use ($id) { |
||
|
0 ignored issues
–
show
|
|||
| 34 | 23 | return $this->roleRepository->getById($id); |
|
| 35 | 23 | }); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 36 | } |
||
| 37 | |||
| 38 | /** |
||
|
0 ignored issues
–
show
|
|||
| 39 | * @inheritDoc |
||
| 40 | */ |
||
|
0 ignored issues
–
show
|
|||
| 41 | 2 | public function all(): Collection |
|
| 42 | { |
||
| 43 | 2 | return $this->roleRepository->all(); |
|
| 44 | } |
||
| 45 | |||
| 46 | /** |
||
|
0 ignored issues
–
show
|
|||
| 47 | * @inheritDoc |
||
| 48 | */ |
||
|
0 ignored issues
–
show
|
|||
| 49 | 3 | public function getByDataProviderId(int $dataProviderId): RoleModel |
|
| 50 | { |
||
| 51 | return $this->cache->rememberForever(static::class . '@getByDataProviderId:' . $dataProviderId, function() use ($dataProviderId) { |
||
|
0 ignored issues
–
show
|
|||
| 52 | 3 | return $this->roleRepository->getByDataProviderId($dataProviderId); |
|
| 53 | 3 | }); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 54 | } |
||
| 55 | |||
| 56 | /** |
||
|
0 ignored issues
–
show
|
|||
| 57 | * @inheritDoc |
||
| 58 | */ |
||
|
0 ignored issues
–
show
|
|||
| 59 | 3 | public function create(int $positionId, int $groupId, int $dataProviderId): RoleModel |
|
| 60 | { |
||
| 61 | 3 | return $this->roleRepository->create($positionId, $groupId, $dataProviderId); |
|
| 62 | } |
||
| 63 | |||
| 64 | /** |
||
|
0 ignored issues
–
show
|
|||
| 65 | * @inheritDoc |
||
| 66 | */ |
||
|
0 ignored issues
–
show
|
|||
| 67 | 2 | public function delete(int $id): void |
|
| 68 | { |
||
| 69 | 2 | $this->roleRepository->delete($id); |
|
| 70 | 2 | } |
|
| 71 | |||
| 72 | /** |
||
|
0 ignored issues
–
show
|
|||
| 73 | * @inheritDoc |
||
| 74 | */ |
||
|
0 ignored issues
–
show
|
|||
| 75 | 5 | public function allThroughGroup(\BristolSU\ControlDB\Contracts\Models\Group $group): Collection |
|
| 76 | { |
||
| 77 | return $this->cache->rememberForever(static::class . '@allThroughGroup:' . $group->id(), function() use ($group) { |
||
|
0 ignored issues
–
show
|
|||
| 78 | 5 | return $this->roleRepository->allThroughGroup($group); |
|
| 79 | 5 | }); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 80 | } |
||
| 81 | |||
| 82 | /** |
||
|
0 ignored issues
–
show
|
|||
| 83 | * @inheritDoc |
||
| 84 | */ |
||
|
0 ignored issues
–
show
|
|||
| 85 | 5 | public function allThroughPosition(\BristolSU\ControlDB\Contracts\Models\Position $position): Collection |
|
| 86 | { |
||
| 87 | return $this->cache->rememberForever(static::class . '@allThroughPosition:' . $position->id(), function() use ($position) { |
||
|
0 ignored issues
–
show
|
|||
| 88 | 5 | return $this->roleRepository->allThroughPosition($position); |
|
| 89 | 5 | }); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 90 | } |
||
| 91 | |||
| 92 | /** |
||
| 93 | * Paginate through all the roles |
||
| 94 | * |
||
| 95 | * @param int $page The page number to return |
||
|
0 ignored issues
–
show
|
|||
| 96 | * @param int $perPage The number of results to return per page |
||
| 97 | * |
||
| 98 | * @return Collection|RoleModel[] |
||
| 99 | */ |
||
| 100 | 3 | public function paginate(int $page, int $perPage): Collection |
|
| 101 | { |
||
| 102 | 3 | return $this->roleRepository->paginate($page, $perPage); |
|
| 103 | } |
||
| 104 | |||
| 105 | /** |
||
| 106 | * Get the number of roles |
||
| 107 | * |
||
| 108 | * @return int |
||
| 109 | */ |
||
| 110 | 3 | public function count(): int |
|
| 111 | { |
||
| 112 | return $this->cache->rememberForever(static::class . '@count', function() { |
||
|
0 ignored issues
–
show
|
|||
| 113 | 3 | return $this->roleRepository->count(); |
|
| 114 | 3 | }); |
|
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||
| 115 | |||
| 116 | } |
||
| 117 | |||
| 118 | /** |
||
| 119 | * Update the role model |
||
| 120 | * |
||
| 121 | * @param int $id |
||
|
0 ignored issues
–
show
|
|||
| 122 | * @param int $positionId |
||
|
0 ignored issues
–
show
|
|||
| 123 | * @param int $groupId |
||
|
0 ignored issues
–
show
|
|||
| 124 | * @param int $dataProviderId New data provider ID |
||
| 125 | * @return RoleModel |
||
|
0 ignored issues
–
show
|
|||
| 126 | */ |
||
| 127 | 6 | public function update(int $id, int $positionId, int $groupId, int $dataProviderId): RoleModel |
|
| 128 | { |
||
| 129 | 6 | return $this->roleRepository->update($id, $positionId, $groupId, $dataProviderId); |
|
| 130 | } |
||
| 131 | } |