@@ -25,48 +25,48 @@ |
||
| 25 | 25 | class LocationCollection extends ArrayCollection |
| 26 | 26 | { |
| 27 | 27 | |
| 28 | - /** |
|
| 29 | - * Adds a location at the end of the collection if it does not already exist. |
|
| 30 | - * |
|
| 31 | - * @param mixed $location The location to add. |
|
| 32 | - * |
|
| 33 | - * @return boolean Whether the location was added or not. |
|
| 34 | - */ |
|
| 35 | - public function add($location) |
|
| 36 | - { |
|
| 37 | - if ($this->hasLocation($location)) { |
|
| 38 | - return false; |
|
| 39 | - } |
|
| 28 | + /** |
|
| 29 | + * Adds a location at the end of the collection if it does not already exist. |
|
| 30 | + * |
|
| 31 | + * @param mixed $location The location to add. |
|
| 32 | + * |
|
| 33 | + * @return boolean Whether the location was added or not. |
|
| 34 | + */ |
|
| 35 | + public function add($location) |
|
| 36 | + { |
|
| 37 | + if ($this->hasLocation($location)) { |
|
| 38 | + return false; |
|
| 39 | + } |
|
| 40 | 40 | |
| 41 | - return parent::add($location); |
|
| 42 | - } |
|
| 41 | + return parent::add($location); |
|
| 42 | + } |
|
| 43 | 43 | |
| 44 | - /** |
|
| 45 | - * Check whether a given location is already registered. |
|
| 46 | - * |
|
| 47 | - * For two locations to be equal, both their path and their extensions must be the same. |
|
| 48 | - * |
|
| 49 | - * @since 0.1.1 |
|
| 50 | - * |
|
| 51 | - * @param LocationInterface $location Location to check the existence of. |
|
| 52 | - * |
|
| 53 | - * @return bool Whether the location is already registered or not. |
|
| 54 | - * |
|
| 55 | - * @throws InvalidLocationException If the location is not valid. |
|
| 56 | - */ |
|
| 57 | - public function hasLocation($location) |
|
| 58 | - { |
|
| 59 | - if (! $location instanceof LocationInterface) { |
|
| 60 | - throw new InvalidLocationException( |
|
| 61 | - sprintf( |
|
| 62 | - _('Invalid location to check existence for: "%s".'), |
|
| 63 | - serialize($location) |
|
| 64 | - ) |
|
| 65 | - ); |
|
| 66 | - } |
|
| 44 | + /** |
|
| 45 | + * Check whether a given location is already registered. |
|
| 46 | + * |
|
| 47 | + * For two locations to be equal, both their path and their extensions must be the same. |
|
| 48 | + * |
|
| 49 | + * @since 0.1.1 |
|
| 50 | + * |
|
| 51 | + * @param LocationInterface $location Location to check the existence of. |
|
| 52 | + * |
|
| 53 | + * @return bool Whether the location is already registered or not. |
|
| 54 | + * |
|
| 55 | + * @throws InvalidLocationException If the location is not valid. |
|
| 56 | + */ |
|
| 57 | + public function hasLocation($location) |
|
| 58 | + { |
|
| 59 | + if (! $location instanceof LocationInterface) { |
|
| 60 | + throw new InvalidLocationException( |
|
| 61 | + sprintf( |
|
| 62 | + _('Invalid location to check existence for: "%s".'), |
|
| 63 | + serialize($location) |
|
| 64 | + ) |
|
| 65 | + ); |
|
| 66 | + } |
|
| 67 | 67 | |
| 68 | - return $this->exists(function ($key, $element) use ($location) { |
|
| 69 | - return $location == $element; |
|
| 70 | - }); |
|
| 71 | - } |
|
| 68 | + return $this->exists(function ($key, $element) use ($location) { |
|
| 69 | + return $location == $element; |
|
| 70 | + }); |
|
| 71 | + } |
|
| 72 | 72 | } |
@@ -56,7 +56,7 @@ discard block |
||
| 56 | 56 | */ |
| 57 | 57 | public function hasLocation($location) |
| 58 | 58 | { |
| 59 | - if (! $location instanceof LocationInterface) { |
|
| 59 | + if ( ! $location instanceof LocationInterface) { |
|
| 60 | 60 | throw new InvalidLocationException( |
| 61 | 61 | sprintf( |
| 62 | 62 | _('Invalid location to check existence for: "%s".'), |
@@ -65,7 +65,7 @@ discard block |
||
| 65 | 65 | ); |
| 66 | 66 | } |
| 67 | 67 | |
| 68 | - return $this->exists(function ($key, $element) use ($location) { |
|
| 68 | + return $this->exists(function($key, $element) use ($location) { |
|
| 69 | 69 | return $location == $element; |
| 70 | 70 | }); |
| 71 | 71 | } |