@@ -21,7 +21,7 @@ discard block |
||
21 | 21 | protected $image; |
22 | 22 | protected $video; |
23 | 23 | |
24 | - public function __construct( Gallery $gallery, Image $image, Video $video ) |
|
24 | + public function __construct(Gallery $gallery, Image $image, Video $video) |
|
25 | 25 | { |
26 | 26 | $this->gallery = $gallery; |
27 | 27 | $this->image = $image; |
@@ -34,19 +34,19 @@ discard block |
||
34 | 34 | * @return string|void |
35 | 35 | * @throws BadMethodCallException |
36 | 36 | */ |
37 | - public function __call( $name, array $args ) |
|
37 | + public function __call($name, array $args) |
|
38 | 38 | { |
39 | - $mediaType = $this->validateMethod( $name ); |
|
39 | + $mediaType = $this->validateMethod($name); |
|
40 | 40 | |
41 | - if( !count( $args )) { |
|
42 | - throw new BadMethodCallException( sprintf( 'Missing arguments for: %s', $name )); |
|
41 | + if (!count($args)) { |
|
42 | + throw new BadMethodCallException(sprintf('Missing arguments for: %s', $name)); |
|
43 | 43 | } |
44 | - if( str_replace( $mediaType, '', strtolower( $name ))) { |
|
45 | - return $this->$mediaType->get( $args[0] )->$mediaType; |
|
44 | + if (str_replace($mediaType, '', strtolower($name))) { |
|
45 | + return $this->$mediaType->get($args[0])->$mediaType; |
|
46 | 46 | } |
47 | - return !empty( $args[1] ) |
|
48 | - ? $this->$mediaType->get( $args[0] )->render( $args[1] ) |
|
49 | - : $this->$mediaType->get( $args[0] )->render(); |
|
47 | + return !empty($args[1]) |
|
48 | + ? $this->$mediaType->get($args[0])->render($args[1]) |
|
49 | + : $this->$mediaType->get($args[0])->render(); |
|
50 | 50 | } |
51 | 51 | |
52 | 52 | /** |
@@ -55,10 +55,10 @@ discard block |
||
55 | 55 | * |
56 | 56 | * @return mixed |
57 | 57 | */ |
58 | - public function get( $name, $args = [] ) |
|
58 | + public function get($name, $args = []) |
|
59 | 59 | { |
60 | - if( $mediaType = $this->validateMethod( $name )) { |
|
61 | - return $this->$mediaType->get( $args )->$mediaType; |
|
60 | + if ($mediaType = $this->validateMethod($name)) { |
|
61 | + return $this->$mediaType->get($args)->$mediaType; |
|
62 | 62 | } |
63 | 63 | } |
64 | 64 | |
@@ -67,15 +67,15 @@ discard block |
||
67 | 67 | * |
68 | 68 | * @return string|false |
69 | 69 | */ |
70 | - protected function validateMethod( $name ) |
|
70 | + protected function validateMethod($name) |
|
71 | 71 | { |
72 | - foreach( [$name, strtolower( substr( $name, 3 ))] as $method ) { |
|
73 | - if( in_array( $method, ['gallery', 'image', 'video'] ) |
|
74 | - && property_exists( $this, $method ) |
|
75 | - && is_object( $this->$method )) { |
|
72 | + foreach ([$name, strtolower(substr($name, 3))] as $method) { |
|
73 | + if (in_array($method, ['gallery', 'image', 'video']) |
|
74 | + && property_exists($this, $method) |
|
75 | + && is_object($this->$method)) { |
|
76 | 76 | return $method; |
77 | 77 | } |
78 | 78 | } |
79 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
79 | + throw new BadMethodCallException(sprintf('Not a valid method: %s', $name)); |
|
80 | 80 | } |
81 | 81 | } |