1 | <?php |
||
11 | class Mutator implements MutatorContract |
||
12 | { |
||
13 | use Macroable; |
||
14 | |||
15 | /** |
||
16 | * Mutate value using provided methods. |
||
17 | * |
||
18 | * @param mixed $value |
||
19 | * @param string|array $callables |
||
20 | * @return mixed |
||
21 | * |
||
22 | * @throws \LogicException |
||
23 | */ |
||
24 | public function mutate($value, $callables) |
||
38 | |||
39 | /** |
||
40 | * Parse provided mutator functions. |
||
41 | * |
||
42 | * @param string $callable |
||
43 | * @return array |
||
44 | * |
||
45 | * @throws \Sofa\Eloquence\Mutator\InvalidCallableException |
||
46 | */ |
||
47 | protected function parse($callable) |
||
61 | |||
62 | /** |
||
63 | * Determine whether callable is a class method. |
||
64 | * |
||
65 | * @param string $callable |
||
66 | * @return boolean |
||
67 | */ |
||
68 | protected function isClassMethod($callable) |
||
72 | |||
73 | /** |
||
74 | * Determine whether callable is available on this instance. |
||
75 | * |
||
76 | * @param string $callable |
||
77 | * @return boolean |
||
78 | */ |
||
79 | protected function isMutatorMethod($callable) |
||
83 | |||
84 | /** |
||
85 | * Split provided string into callable and arguments. |
||
86 | * |
||
87 | * @param string $callable |
||
88 | * @return array |
||
89 | */ |
||
90 | protected function parseArgs($callable) |
||
102 | |||
103 | /** |
||
104 | * Extract and validate class method. |
||
105 | * |
||
106 | * @param string $userCallable |
||
107 | * @return callable |
||
108 | * |
||
109 | * @throws \Sofa\Eloquence\Mutator\InvalidCallableException |
||
110 | */ |
||
111 | protected function parseClassMethod($userCallable) |
||
127 | |||
128 | /** |
||
129 | * Get instance callable. |
||
130 | * |
||
131 | * @param \ReflectionMethod $method |
||
132 | * @return callable |
||
133 | * |
||
134 | * @throws \Sofa\Eloquence\Mutator\InvalidCallableException |
||
135 | */ |
||
136 | protected function getInstanceMethod(ReflectionClass $class, ReflectionMethod $method) |
||
148 | |||
149 | /** |
||
150 | * Determine whether instance can be instantiated. |
||
151 | * |
||
152 | * @param \ReflectionClass $class |
||
153 | * @return boolean |
||
154 | */ |
||
155 | protected function canInstantiate(ReflectionClass $class) |
||
165 | } |
||
166 |