Total Complexity | 7 |
Total Lines | 40 |
Duplicated Lines | 0 % |
Coverage | 33.33% |
Changes | 0 |
1 | <?php |
||
15 | class UserService implements UserServiceContract |
||
16 | { |
||
17 | 2 | public function find($id): ?User |
|
18 | { |
||
19 | return Cache::remember($this->getCacheName($id), $this->getCacheTime(), function () use ($id) { |
||
20 | 2 | return User::find($id); |
|
21 | 2 | }); |
|
22 | } |
||
23 | |||
24 | public function update($id, $data): ?User |
||
30 | } |
||
31 | |||
32 | public function create($data): User |
||
33 | { |
||
34 | $user = User::create($data); |
||
35 | Cache::put($this->getCacheName($user->id), $user, $this->getCacheTime()); |
||
36 | return $user; |
||
37 | } |
||
38 | |||
39 | public function delete($id): bool |
||
45 | } |
||
46 | |||
47 | 2 | protected function getCacheName($id) |
|
48 | { |
||
49 | 2 | return "user:$id"; |
|
50 | } |
||
51 | |||
52 | 2 | protected function getCacheTime() |
|
55 | } |
||
56 | } |
||
57 |