@@ 45-58 (lines=14) @@ | ||
42 | * @param mixed $data |
|
43 | * @return string |
|
44 | */ |
|
45 | public function resolve($data) |
|
46 | { |
|
47 | $transformable = $this->resolveTransformableItem($data); |
|
48 | ||
49 | if (is_object($transformable) && key_exists(get_class($transformable), $this->bindings)) { |
|
50 | return $this->bindings[get_class($transformable)]; |
|
51 | } |
|
52 | ||
53 | if ($transformable instanceof Model) { |
|
54 | return $this->resolveFromModel($transformable); |
|
55 | } |
|
56 | ||
57 | return 'data'; |
|
58 | } |
|
59 | ||
60 | /** |
|
61 | * Resolve a resource key from the given model. |
@@ 106-117 (lines=12) @@ | ||
103 | * @param mixed $transformable |
|
104 | * @return \Flugg\Responder\Contracts\Transformable|callable |
|
105 | */ |
|
106 | protected function resolveTransformer($transformable) |
|
107 | { |
|
108 | if (is_object($transformable) && key_exists(get_class($transformable), $this->bindings)) { |
|
109 | return $this->bindings[get_class($transformable)]; |
|
110 | } |
|
111 | ||
112 | if ($transformable instanceof Transformable) { |
|
113 | return $transformable->transformer(); |
|
114 | } |
|
115 | ||
116 | return $this->resolve($this->fallback); |
|
117 | } |
|
118 | ||
119 | /** |
|
120 | * Resolve a transformable item from the given data. |