@@ -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,21 +34,21 @@ 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 ); |
|
| 40 | - if( $mediaType === false ) { |
|
| 41 | - throw new BadMethodCallException( sprintf( 'Not a valid method: %s', $name )); |
|
| 39 | + $mediaType = $this->validateMethod($name); |
|
| 40 | + if ($mediaType === false) { |
|
| 41 | + throw new BadMethodCallException(sprintf('Not a valid method: %s', $name)); |
|
| 42 | 42 | } |
| 43 | - if( !count( $args )) { |
|
| 44 | - throw new BadMethodCallException( sprintf( 'Missing arguments for: %s', $name )); |
|
| 43 | + if (!count($args)) { |
|
| 44 | + throw new BadMethodCallException(sprintf('Missing arguments for: %s', $name)); |
|
| 45 | 45 | } |
| 46 | - if( str_replace( $mediaType, '', strtolower( $name ))) { |
|
| 47 | - return $this->$mediaType->get( $args[0] )->$mediaType; |
|
| 46 | + if (str_replace($mediaType, '', strtolower($name))) { |
|
| 47 | + return $this->$mediaType->get($args[0])->$mediaType; |
|
| 48 | 48 | } |
| 49 | - return !empty( $args[1] ) |
|
| 50 | - ? $this->$mediaType->get( $args[0] )->render( $args[1] ) |
|
| 51 | - : $this->$mediaType->get( $args[0] )->render(); |
|
| 49 | + return !empty($args[1]) |
|
| 50 | + ? $this->$mediaType->get($args[0])->render($args[1]) |
|
| 51 | + : $this->$mediaType->get($args[0])->render(); |
|
| 52 | 52 | } |
| 53 | 53 | |
| 54 | 54 | /** |
@@ -57,10 +57,10 @@ discard block |
||
| 57 | 57 | * |
| 58 | 58 | * @return mixed |
| 59 | 59 | */ |
| 60 | - public function get( $name, $args = [] ) |
|
| 60 | + public function get($name, $args = []) |
|
| 61 | 61 | { |
| 62 | - if( $mediaType = $this->validateMethod( $name )) { |
|
| 63 | - return $this->$mediaType->get( $args )->$mediaType; |
|
| 62 | + if ($mediaType = $this->validateMethod($name)) { |
|
| 63 | + return $this->$mediaType->get($args)->$mediaType; |
|
| 64 | 64 | } |
| 65 | 65 | } |
| 66 | 66 | |
@@ -69,12 +69,12 @@ discard block |
||
| 69 | 69 | * |
| 70 | 70 | * @return string|false |
| 71 | 71 | */ |
| 72 | - protected function validateMethod( $name ) |
|
| 72 | + protected function validateMethod($name) |
|
| 73 | 73 | { |
| 74 | - foreach( [$name, strtolower( substr( $name, 3 ))] as $method ) { |
|
| 75 | - if( in_array( $method, ['gallery', 'image', 'video'] ) |
|
| 76 | - && property_exists( $this, $method ) |
|
| 77 | - && is_object( $this->$method )) { |
|
| 74 | + foreach ([$name, strtolower(substr($name, 3))] as $method) { |
|
| 75 | + if (in_array($method, ['gallery', 'image', 'video']) |
|
| 76 | + && property_exists($this, $method) |
|
| 77 | + && is_object($this->$method)) { |
|
| 78 | 78 | return $method; |
| 79 | 79 | } |
| 80 | 80 | } |