@@ -29,14 +29,14 @@ discard block |
||
29 | 29 | * |
30 | 30 | * @var array |
31 | 31 | */ |
32 | - protected $bindings = []; |
|
32 | + protected $bindings = [ ]; |
|
33 | 33 | |
34 | 34 | /** |
35 | 35 | * Construct the resolver class. |
36 | 36 | * |
37 | 37 | * @param \Illuminate\Contracts\Container\Container $container |
38 | 38 | */ |
39 | - public function __construct(Container $container) |
|
39 | + public function __construct( Container $container ) |
|
40 | 40 | { |
41 | 41 | $this->container = $container; |
42 | 42 | } |
@@ -48,11 +48,11 @@ discard block |
||
48 | 48 | * @param string|callback $transformer |
49 | 49 | * @return void |
50 | 50 | */ |
51 | - public function bind($transformable, $transformer) |
|
51 | + public function bind( $transformable, $transformer ) |
|
52 | 52 | { |
53 | - $this->bindings = array_merge($this->bindings, is_array($transformable) ? $transformable : [ |
|
53 | + $this->bindings = array_merge( $this->bindings, is_array( $transformable ) ? $transformable : [ |
|
54 | 54 | $transformable => $transformer, |
55 | - ]); |
|
55 | + ] ); |
|
56 | 56 | } |
57 | 57 | |
58 | 58 | /** |
@@ -62,13 +62,13 @@ discard block |
||
62 | 62 | * @return \Flugg\Responder\Transformers\Transformer|callable |
63 | 63 | * @throws \Flugg\Responder\Exceptions\InvalidTransformerException |
64 | 64 | */ |
65 | - public function resolve($transformer) |
|
65 | + public function resolve( $transformer ) |
|
66 | 66 | { |
67 | - if (is_string($transformer)) { |
|
68 | - return $this->container->make($transformer); |
|
67 | + if ( is_string( $transformer ) ) { |
|
68 | + return $this->container->make( $transformer ); |
|
69 | 69 | } |
70 | 70 | |
71 | - if (! is_callable($transformer) && ! $transformer instanceof Transformer) { |
|
71 | + if ( ! is_callable( $transformer ) && ! $transformer instanceof Transformer ) { |
|
72 | 72 | throw new InvalidTransformerException; |
73 | 73 | } |
74 | 74 | |
@@ -81,11 +81,11 @@ discard block |
||
81 | 81 | * @param mixed $data |
82 | 82 | * @return \Flugg\Responder\Transformers\Transformer|callable|null |
83 | 83 | */ |
84 | - public function resolveFromData($data) |
|
84 | + public function resolveFromData( $data ) |
|
85 | 85 | { |
86 | - if ($transformable = $this->resolveTransformable($data)) { |
|
87 | - if ($transformer = $this->resolveTransformer()) { |
|
88 | - return $this->resolve($transformer); |
|
86 | + if ( $transformable = $this->resolveTransformable( $data ) ) { |
|
87 | + if ( $transformer = $this->resolveTransformer() ) { |
|
88 | + return $this->resolve( $transformer ); |
|
89 | 89 | } |
90 | 90 | } |
91 | 91 | |
@@ -98,11 +98,11 @@ discard block |
||
98 | 98 | * @param mixed $data |
99 | 99 | * @return \Flugg\Responder\Contracts\Transformable|null |
100 | 100 | */ |
101 | - protected function resolveTransformable($data) |
|
101 | + protected function resolveTransformable( $data ) |
|
102 | 102 | { |
103 | - if (is_iterable($data)) { |
|
104 | - foreach ($data as $item) { |
|
105 | - if ($item instanceof Transformable) { |
|
103 | + if ( is_iterable( $data ) ) { |
|
104 | + foreach ( $data as $item ) { |
|
105 | + if ( $item instanceof Transformable ) { |
|
106 | 106 | return $item; |
107 | 107 | } |
108 | 108 | } |
@@ -117,10 +117,10 @@ discard block |
||
117 | 117 | * @param \Flugg\Responder\Contracts\Transformable $transformable |
118 | 118 | * @return \Flugg\Responder\Contracts\Transformable|null |
119 | 119 | */ |
120 | - protected function resolveTransformer(Transformable $transformable) |
|
120 | + protected function resolveTransformer( Transformable $transformable ) |
|
121 | 121 | { |
122 | - if (key_exists($this->bindings, get_class($transformable))) { |
|
123 | - return $this->bindings[get_class($transformable)]; |
|
122 | + if ( key_exists( $this->bindings, get_class( $transformable ) ) ) { |
|
123 | + return $this->bindings[ get_class( $transformable ) ]; |
|
124 | 124 | } |
125 | 125 | |
126 | 126 | return $transformable->transformer(); |
@@ -133,7 +133,7 @@ discard block |
||
133 | 133 | */ |
134 | 134 | protected function makeClosureTransformer(): callable |
135 | 135 | { |
136 | - return function ($data) { |
|
136 | + return function ( $data ) { |
|
137 | 137 | return $data instanceof Arrayable ? $data->toArray() : $data; |
138 | 138 | }; |
139 | 139 | } |