1 | <?php |
||
10 | class CacheableDecorator |
||
11 | { |
||
12 | /** |
||
13 | * Cacheable Repository. |
||
14 | * |
||
15 | * @var \Suitmedia\Cacheable\Contracts\CacheableRepository |
||
16 | */ |
||
17 | private $repository; |
||
18 | |||
19 | /** |
||
20 | * Cacheable service object. |
||
21 | * |
||
22 | * @var \Suitmedia\Cacheable\CacheableService |
||
23 | */ |
||
24 | private $service; |
||
25 | |||
26 | /** |
||
27 | * Class constructor. |
||
28 | * |
||
29 | * @param \Suitmedia\Cacheable\CacheableService $service |
||
30 | * @param \Suitmedia\Cacheable\Contracts\CacheableRepository $repository |
||
31 | */ |
||
32 | public function __construct(CacheableService $service, CacheableRepository $repository) |
||
37 | |||
38 | /** |
||
39 | * Generate custom cache tags. |
||
40 | * |
||
41 | * @param \Illuminate\Support\Collection $tags |
||
42 | * @param \Illuminate\Database\Eloquent\Model $object |
||
43 | * |
||
44 | * @return void |
||
45 | */ |
||
46 | private function generateCustomTags(Collection $tags, Model $object): void |
||
57 | |||
58 | /** |
||
59 | * Generate cache tags. |
||
60 | * |
||
61 | * @param mixed $args |
||
62 | * |
||
63 | * @return array |
||
64 | */ |
||
65 | private function generateTags($args): array |
||
78 | |||
79 | /** |
||
80 | * Get the correct return value if the repository returns itself. |
||
81 | * |
||
82 | * @param mixed $value |
||
83 | * |
||
84 | * @return mixed |
||
85 | */ |
||
86 | private function getReturnValue($value) |
||
90 | |||
91 | /** |
||
92 | * Determine if the given object is a custom tag instance. |
||
93 | * |
||
94 | * @param mixed $object |
||
95 | * |
||
96 | * @return bool |
||
97 | */ |
||
98 | private function isCustomTagInstance($object): bool |
||
104 | |||
105 | /** |
||
106 | * Finds whether the method is cacheable. |
||
107 | * |
||
108 | * @param string $method |
||
109 | * |
||
110 | * @return bool |
||
111 | */ |
||
112 | private function methodIsCacheable($method): bool |
||
116 | |||
117 | /** |
||
118 | * Dynamically call methods from repository. |
||
119 | * |
||
120 | * @param string $method |
||
121 | * @param mixed $args |
||
122 | * |
||
123 | * @return mixed |
||
124 | */ |
||
125 | public function __call($method, $args) |
||
151 | } |
||
152 |