PluginProbe
Assistant – Every Day Productivity Apps / trunk
Assistant – Every Day Productivity Apps vtrunk
1.5.5 trunk 0.1.0 0.2.0 0.2.1 0.2.2 0.3.0 0.3.1 0.4 0.4.1 0.4.2 0.5.0 0.5.1 0.6.0 0.7.0 0.7.0.2 0.7.0.3 0.7.0.4 0.7.0.5 0.7.0.6 0.7.0.7 0.7.0.8 0.7.0.9 0.7.1 1.0 All 71 releases
assistant / backend / src / System / Container / InjectionException.php

InjectionException.php in Assistant – Every Day Productivity Apps trunk, at backend/src/System/Container/InjectionException.php

66 lines 1.9 KB
No matching file
Up and down to move Enter to open Esc to close
Raw Download Zip
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 }
66