| @@ -25,74 +25,74 @@ | ||
| 25 | 25 | class JSONLoader extends AbstractLoader | 
| 26 | 26 |  { | 
| 27 | 27 | |
| 28 | - /** | |
| 29 | - * Check whether the loader is able to load a given URI. | |
| 30 | - * | |
| 31 | - * @since 0.4.0 | |
| 32 | - * | |
| 33 | - * @param string $uri URI to check. | |
| 34 | - * | |
| 35 | - * @return bool Whether the loader can load the given URI. | |
| 36 | - */ | |
| 37 | - public static function canLoad($uri) | |
| 38 | -    { | |
| 39 | - $path = pathinfo($uri); | |
| 28 | + /** | |
| 29 | + * Check whether the loader is able to load a given URI. | |
| 30 | + * | |
| 31 | + * @since 0.4.0 | |
| 32 | + * | |
| 33 | + * @param string $uri URI to check. | |
| 34 | + * | |
| 35 | + * @return bool Whether the loader can load the given URI. | |
| 36 | + */ | |
| 37 | + public static function canLoad($uri) | |
| 38 | +	{ | |
| 39 | + $path = pathinfo($uri); | |
| 40 | 40 | |
| 41 | - return 'json' === mb_strtolower($path['extension']); | |
| 42 | - } | |
| 41 | + return 'json' === mb_strtolower($path['extension']); | |
| 42 | + } | |
| 43 | 43 | |
| 44 | - /** | |
| 45 | - * Load the contents of an resource identified by an URI. | |
| 46 | - * | |
| 47 | - * @since 0.4.0 | |
| 48 | - * | |
| 49 | - * @param string $uri URI of the resource. | |
| 50 | - * | |
| 51 | - * @return array|null Raw data loaded from the resource. Null if no data found. | |
| 52 | - * @throws FailedToLoadConfigException If the resource could not be loaded. | |
| 53 | - */ | |
| 54 | - protected function loadUri($uri) | |
| 55 | -    { | |
| 56 | -        try { | |
| 57 | - ob_start(); | |
| 58 | - $data = json_decode(file_get_contents($uri), true); | |
| 59 | - ob_end_clean(); | |
| 44 | + /** | |
| 45 | + * Load the contents of an resource identified by an URI. | |
| 46 | + * | |
| 47 | + * @since 0.4.0 | |
| 48 | + * | |
| 49 | + * @param string $uri URI of the resource. | |
| 50 | + * | |
| 51 | + * @return array|null Raw data loaded from the resource. Null if no data found. | |
| 52 | + * @throws FailedToLoadConfigException If the resource could not be loaded. | |
| 53 | + */ | |
| 54 | + protected function loadUri($uri) | |
| 55 | +	{ | |
| 56 | +		try { | |
| 57 | + ob_start(); | |
| 58 | + $data = json_decode(file_get_contents($uri), true); | |
| 59 | + ob_end_clean(); | |
| 60 | 60 | |
| 61 | - return (array)$data; | |
| 62 | -        } catch (Exception $exception) { | |
| 63 | - throw new FailedToLoadConfigException( | |
| 64 | - sprintf( | |
| 65 | -                    _('Could not include JSON config file "%1$s". Reason: "%2$s".'), | |
| 66 | - $uri, | |
| 67 | - $exception->getMessage() | |
| 68 | - ), | |
| 69 | - $exception->getCode(), | |
| 70 | - $exception | |
| 71 | - ); | |
| 72 | - } | |
| 73 | - } | |
| 61 | + return (array)$data; | |
| 62 | +		} catch (Exception $exception) { | |
| 63 | + throw new FailedToLoadConfigException( | |
| 64 | + sprintf( | |
| 65 | +					_('Could not include JSON config file "%1$s". Reason: "%2$s".'), | |
| 66 | + $uri, | |
| 67 | + $exception->getMessage() | |
| 68 | + ), | |
| 69 | + $exception->getCode(), | |
| 70 | + $exception | |
| 71 | + ); | |
| 72 | + } | |
| 73 | + } | |
| 74 | 74 | |
| 75 | - /** | |
| 76 | - * Validate and return the URI. | |
| 77 | - * | |
| 78 | - * @since 0.4.0 | |
| 79 | - * | |
| 80 | - * @param string $uri URI of the resource to load. | |
| 81 | - * | |
| 82 | - * @return string Validated URI. | |
| 83 | - * @throws FailedToLoadConfigException If the URI does not exist or is not readable. | |
| 84 | - */ | |
| 85 | - protected function validateUri($uri) | |
| 86 | -    { | |
| 87 | -        if (! is_readable($uri)) { | |
| 88 | - throw new FailedToLoadConfigException( | |
| 89 | - sprintf( | |
| 90 | -                    _('The requested JSON config file "%1$s" does not exist or is not readable.'), | |
| 91 | - $uri | |
| 92 | - ) | |
| 93 | - ); | |
| 94 | - } | |
| 75 | + /** | |
| 76 | + * Validate and return the URI. | |
| 77 | + * | |
| 78 | + * @since 0.4.0 | |
| 79 | + * | |
| 80 | + * @param string $uri URI of the resource to load. | |
| 81 | + * | |
| 82 | + * @return string Validated URI. | |
| 83 | + * @throws FailedToLoadConfigException If the URI does not exist or is not readable. | |
| 84 | + */ | |
| 85 | + protected function validateUri($uri) | |
| 86 | +	{ | |
| 87 | +		if (! is_readable($uri)) { | |
| 88 | + throw new FailedToLoadConfigException( | |
| 89 | + sprintf( | |
| 90 | +					_('The requested JSON config file "%1$s" does not exist or is not readable.'), | |
| 91 | + $uri | |
| 92 | + ) | |
| 93 | + ); | |
| 94 | + } | |
| 95 | 95 | |
| 96 | - return $uri; | |
| 97 | - } | |
| 96 | + return $uri; | |
| 97 | + } | |
| 98 | 98 | } | 
| @@ -22,26 +22,26 @@ | ||
| 22 | 22 | interface LoaderInterface | 
| 23 | 23 |  { | 
| 24 | 24 | |
| 25 | - /** | |
| 26 | - * Check whether the loader is able to load a given URI. | |
| 27 | - * | |
| 28 | - * @since 0.4.0 | |
| 29 | - * | |
| 30 | - * @param string $uri URI to check. | |
| 31 | - * | |
| 32 | - * @return bool Whether the loader can load the given URI. | |
| 33 | - */ | |
| 34 | - public static function canLoad($uri); | |
| 25 | + /** | |
| 26 | + * Check whether the loader is able to load a given URI. | |
| 27 | + * | |
| 28 | + * @since 0.4.0 | |
| 29 | + * | |
| 30 | + * @param string $uri URI to check. | |
| 31 | + * | |
| 32 | + * @return bool Whether the loader can load the given URI. | |
| 33 | + */ | |
| 34 | + public static function canLoad($uri); | |
| 35 | 35 | |
| 36 | - /** | |
| 37 | - * Load the configuration from an URI. | |
| 38 | - * | |
| 39 | - * @since 0.4.0 | |
| 40 | - * | |
| 41 | - * @param string $uri URI of the resource to load. | |
| 42 | - * | |
| 43 | - * @return array|null Data contained within the resource. Null if no data could be loaded/parsed. | |
| 44 | - * @throws FailedToLoadConfigException If the configuration could not be loaded. | |
| 45 | - */ | |
| 46 | - public function load($uri); | |
| 36 | + /** | |
| 37 | + * Load the configuration from an URI. | |
| 38 | + * | |
| 39 | + * @since 0.4.0 | |
| 40 | + * | |
| 41 | + * @param string $uri URI of the resource to load. | |
| 42 | + * | |
| 43 | + * @return array|null Data contained within the resource. Null if no data could be loaded/parsed. | |
| 44 | + * @throws FailedToLoadConfigException If the configuration could not be loaded. | |
| 45 | + */ | |
| 46 | + public function load($uri); | |
| 47 | 47 | } | 
| @@ -25,76 +25,76 @@ | ||
| 25 | 25 | class PHPLoader extends AbstractLoader | 
| 26 | 26 |  { | 
| 27 | 27 | |
| 28 | - /** | |
| 29 | - * Check whether the loader is able to load a given URI. | |
| 30 | - * | |
| 31 | - * @since 0.4.0 | |
| 32 | - * | |
| 33 | - * @param string $uri URI to check. | |
| 34 | - * | |
| 35 | - * @return bool Whether the loader can load the given URI. | |
| 36 | - */ | |
| 37 | - public static function canLoad($uri) | |
| 38 | -    { | |
| 39 | - $path = pathinfo($uri); | |
| 28 | + /** | |
| 29 | + * Check whether the loader is able to load a given URI. | |
| 30 | + * | |
| 31 | + * @since 0.4.0 | |
| 32 | + * | |
| 33 | + * @param string $uri URI to check. | |
| 34 | + * | |
| 35 | + * @return bool Whether the loader can load the given URI. | |
| 36 | + */ | |
| 37 | + public static function canLoad($uri) | |
| 38 | +	{ | |
| 39 | + $path = pathinfo($uri); | |
| 40 | 40 | |
| 41 | - return 'php' === mb_strtolower($path['extension']); | |
| 42 | - } | |
| 41 | + return 'php' === mb_strtolower($path['extension']); | |
| 42 | + } | |
| 43 | 43 | |
| 44 | - /** | |
| 45 | - * Load the contents of an resource identified by an URI. | |
| 46 | - * | |
| 47 | - * @since 0.4.0 | |
| 48 | - * | |
| 49 | - * @param string $uri URI of the resource. | |
| 50 | - * | |
| 51 | - * @return array|null Raw data loaded from the resource. Null if no data found. | |
| 52 | - * @throws FailedToLoadConfigException If the resource could not be loaded. | |
| 53 | - */ | |
| 54 | - protected function loadUri($uri) | |
| 55 | -    { | |
| 56 | -        try { | |
| 57 | - // Try to load the file through PHP's include(). | |
| 58 | - // Make sure we don't accidentally create output. | |
| 59 | - ob_start(); | |
| 60 | - $data = include($uri); | |
| 61 | - ob_end_clean(); | |
| 44 | + /** | |
| 45 | + * Load the contents of an resource identified by an URI. | |
| 46 | + * | |
| 47 | + * @since 0.4.0 | |
| 48 | + * | |
| 49 | + * @param string $uri URI of the resource. | |
| 50 | + * | |
| 51 | + * @return array|null Raw data loaded from the resource. Null if no data found. | |
| 52 | + * @throws FailedToLoadConfigException If the resource could not be loaded. | |
| 53 | + */ | |
| 54 | + protected function loadUri($uri) | |
| 55 | +	{ | |
| 56 | +		try { | |
| 57 | + // Try to load the file through PHP's include(). | |
| 58 | + // Make sure we don't accidentally create output. | |
| 59 | + ob_start(); | |
| 60 | + $data = include($uri); | |
| 61 | + ob_end_clean(); | |
| 62 | 62 | |
| 63 | - return $data; | |
| 64 | -        } catch (Exception $exception) { | |
| 65 | - throw new FailedToLoadConfigException( | |
| 66 | - sprintf( | |
| 67 | -                    _('Could not include PHP config file "%1$s". Reason: "%2$s".'), | |
| 68 | - $uri, | |
| 69 | - $exception->getMessage() | |
| 70 | - ), | |
| 71 | - $exception->getCode(), | |
| 72 | - $exception | |
| 73 | - ); | |
| 74 | - } | |
| 75 | - } | |
| 63 | + return $data; | |
| 64 | +		} catch (Exception $exception) { | |
| 65 | + throw new FailedToLoadConfigException( | |
| 66 | + sprintf( | |
| 67 | +					_('Could not include PHP config file "%1$s". Reason: "%2$s".'), | |
| 68 | + $uri, | |
| 69 | + $exception->getMessage() | |
| 70 | + ), | |
| 71 | + $exception->getCode(), | |
| 72 | + $exception | |
| 73 | + ); | |
| 74 | + } | |
| 75 | + } | |
| 76 | 76 | |
| 77 | - /** | |
| 78 | - * Validate and return the URI. | |
| 79 | - * | |
| 80 | - * @since 0.4.0 | |
| 81 | - * | |
| 82 | - * @param string $uri URI of the resource to load. | |
| 83 | - * | |
| 84 | - * @return string Validated URI. | |
| 85 | - * @throws FailedToLoadConfigException If the URI does not exist or is not readable. | |
| 86 | - */ | |
| 87 | - protected function validateUri($uri) | |
| 88 | -    { | |
| 89 | -        if (! is_readable($uri)) { | |
| 90 | - throw new FailedToLoadConfigException( | |
| 91 | - sprintf( | |
| 92 | -                    _('The requested PHP config file "%1$s" does not exist or is not readable.'), | |
| 93 | - $uri | |
| 94 | - ) | |
| 95 | - ); | |
| 96 | - } | |
| 77 | + /** | |
| 78 | + * Validate and return the URI. | |
| 79 | + * | |
| 80 | + * @since 0.4.0 | |
| 81 | + * | |
| 82 | + * @param string $uri URI of the resource to load. | |
| 83 | + * | |
| 84 | + * @return string Validated URI. | |
| 85 | + * @throws FailedToLoadConfigException If the URI does not exist or is not readable. | |
| 86 | + */ | |
| 87 | + protected function validateUri($uri) | |
| 88 | +	{ | |
| 89 | +		if (! is_readable($uri)) { | |
| 90 | + throw new FailedToLoadConfigException( | |
| 91 | + sprintf( | |
| 92 | +					_('The requested PHP config file "%1$s" does not exist or is not readable.'), | |
| 93 | + $uri | |
| 94 | + ) | |
| 95 | + ); | |
| 96 | + } | |
| 97 | 97 | |
| 98 | - return $uri; | |
| 99 | - } | |
| 98 | + return $uri; | |
| 99 | + } | |
| 100 | 100 | } |