| @@ -1,65 +1,65 @@ | ||
| 1 | -<?php | |
| 2 | - | |
| 3 | -namespace FL\Assistant\System\Container; | |
| 4 | - | |
| 5 | -class InjectionException extends InjectorException { | |
| 6 | - | |
| 7 | - public $dependencyChain; | |
| 8 | - | |
| 9 | - public function __construct( array $inProgressMakes, $message = '', $code = 0, \Exception $previous = null ) { | |
| 10 | - $this->dependencyChain = array_flip( $inProgressMakes ); | |
| 11 | - ksort( $this->dependencyChain ); | |
| 12 | - | |
| 13 | - parent::__construct( $message, $code, $previous ); | |
| 14 | - } | |
| 15 | - | |
| 16 | - /** | |
| 17 | - * Add a human readable version of the invalid callable to the standard 'invalid invokable' message. | |
| 18 | - */ | |
| 19 | - public static function fromInvalidCallable( | |
| 20 | - array $inProgressMakes, | |
| 21 | - $callableOrMethodStr, | |
| 22 | - \Exception $previous = null | |
| 23 | - ) { | |
| 24 | - $callableString = null; | |
| 25 | - | |
| 26 | - if ( is_string( $callableOrMethodStr ) ) { | |
| 27 | - $callableString .= $callableOrMethodStr; | |
| 28 | - } elseif ( is_array( $callableOrMethodStr ) && | |
| 29 | - array_key_exists( 0, $callableOrMethodStr ) && | |
| 30 | - array_key_exists( 0, $callableOrMethodStr ) ) { | |
| 31 | - if ( is_string( $callableOrMethodStr[0] ) && is_string( $callableOrMethodStr[1] ) ) { | |
| 32 | - $callableString .= $callableOrMethodStr[0] . '::' . $callableOrMethodStr[1]; | |
| 33 | - } elseif ( is_object( $callableOrMethodStr[0] ) && is_string( $callableOrMethodStr[1] ) ) { | |
| 34 | - $callableString .= sprintf( | |
| 35 | - "[object(%s), '%s']", | |
| 36 | - get_class( $callableOrMethodStr[0] ), | |
| 37 | - $callableOrMethodStr[1] | |
| 38 | - ); | |
| 39 | - } | |
| 40 | - } | |
| 41 | - | |
| 42 | - if ( $callableString ) { | |
| 43 | - // Prevent accidental usage of long strings from filling logs. | |
| 44 | - $callableString = substr( $callableString, 0, 250 ); | |
| 45 | - $message = sprintf( | |
| 46 | - "%s. Invalid callable was '%s'", | |
| 47 | - Injector::M_INVOKABLE, | |
| 48 | - $callableString | |
| 49 | - ); | |
| 50 | - } else { | |
| 51 | - $message = \Auryn\Injector::M_INVOKABLE; | |
| 52 | - } | |
| 53 | - | |
| 54 | - return new self( $inProgressMakes, $message, Injector::E_INVOKABLE, $previous ); | |
| 55 | - } | |
| 56 | - | |
| 57 | - /** | |
| 58 | - * Returns the hierarchy of dependencies that were being created when | |
| 59 | - * the exception occurred. | |
| 60 | - * @return array | |
| 61 | - */ | |
| 62 | - public function getDependencyChain() { | |
| 63 | - return $this->dependencyChain; | |
| 64 | - } | |
| 65 | -} | |
| 1 | +<?php | |
| 2 | + | |
| 3 | +namespace FL\Assistant\System\Container; | |
| 4 | + | |
| 5 | +class InjectionException extends InjectorException { | |
| 6 | + | |
| 7 | + public $dependencyChain; | |
| 8 | + | |
| 9 | + public function __construct( array $inProgressMakes, $message = '', $code = 0, \Exception $previous = null ) { | |
| 10 | + $this->dependencyChain = array_flip( $inProgressMakes ); | |
| 11 | + ksort( $this->dependencyChain ); | |
| 12 | + | |
| 13 | + parent::__construct( $message, $code, $previous ); | |
| 14 | + } | |
| 15 | + | |
| 16 | + /** | |
| 17 | + * Add a human readable version of the invalid callable to the standard 'invalid invokable' message. | |
| 18 | + */ | |
| 19 | + public static function fromInvalidCallable( | |
| 20 | + array $inProgressMakes, | |
| 21 | + $callableOrMethodStr, | |
| 22 | + \Exception $previous = null | |
| 23 | + ) { | |
| 24 | + $callableString = null; | |
| 25 | + | |
| 26 | + if ( is_string( $callableOrMethodStr ) ) { | |
| 27 | + $callableString .= $callableOrMethodStr; | |
| 28 | + } elseif ( is_array( $callableOrMethodStr ) && | |
| 29 | + array_key_exists( 0, $callableOrMethodStr ) && | |
| 30 | + array_key_exists( 0, $callableOrMethodStr ) ) { | |
| 31 | + if ( is_string( $callableOrMethodStr[0] ) && is_string( $callableOrMethodStr[1] ) ) { | |
| 32 | + $callableString .= $callableOrMethodStr[0] . '::' . $callableOrMethodStr[1]; | |
| 33 | + } elseif ( is_object( $callableOrMethodStr[0] ) && is_string( $callableOrMethodStr[1] ) ) { | |
| 34 | + $callableString .= sprintf( | |
| 35 | + "[object(%s), '%s']", | |
| 36 | + get_class( $callableOrMethodStr[0] ), | |
| 37 | + $callableOrMethodStr[1] | |
| 38 | + ); | |
| 39 | + } | |
| 40 | + } | |
| 41 | + | |
| 42 | + if ( $callableString ) { | |
| 43 | + // Prevent accidental usage of long strings from filling logs. | |
| 44 | + $callableString = substr( $callableString, 0, 250 ); | |
| 45 | + $message = sprintf( | |
| 46 | + "%s. Invalid callable was '%s'", | |
| 47 | + Injector::M_INVOKABLE, | |
| 48 | + $callableString | |
| 49 | + ); | |
| 50 | + } else { | |
| 51 | + $message = \Auryn\Injector::M_INVOKABLE; | |
| 52 | + } | |
| 53 | + | |
| 54 | + return new self( $inProgressMakes, $message, Injector::E_INVOKABLE, $previous ); | |
| 55 | + } | |
| 56 | + | |
| 57 | + /** | |
| 58 | + * Returns the hierarchy of dependencies that were being created when | |
| 59 | + * the exception occurred. | |
| 60 | + * @return array | |
| 61 | + */ | |
| 62 | + public function getDependencyChain() { | |
| 63 | + return $this->dependencyChain; | |
| 64 | + } | |
| 65 | +} | |