1 | <?php |
||
20 | class ObjectIdentifier |
||
21 | { |
||
22 | |||
23 | /** |
||
24 | * used to separate the FQCN from the class's arguments identifier |
||
25 | */ |
||
26 | const DELIMITER = '____'; |
||
27 | |||
28 | /** |
||
29 | * @var ClassInterfaceCache $class_cache |
||
30 | */ |
||
31 | private $class_cache; |
||
32 | |||
33 | |||
34 | /** |
||
35 | * ObjectIdentifier constructor. |
||
36 | * |
||
37 | * @param ClassInterfaceCache $class_cache |
||
38 | */ |
||
39 | public function __construct(ClassInterfaceCache $class_cache) |
||
43 | |||
44 | |||
45 | /** |
||
46 | * Returns true if the supplied $object_identifier contains |
||
47 | * the delimiter used to separate an fqcn from the arguments hash |
||
48 | * |
||
49 | * @param string $object_identifier |
||
50 | * @return bool |
||
51 | */ |
||
52 | public function hasArguments($object_identifier) |
||
59 | |||
60 | |||
61 | /** |
||
62 | * Returns true if the supplied FQCN equals the supplied $object_identifier |
||
63 | * OR the supplied FQCN matches the FQCN portion of the supplied $object_identifier |
||
64 | * AND that $object_identifier is for an object with arguments. |
||
65 | * This allows a request for an object using a FQCN to match |
||
66 | * a previously instantiated object with arguments |
||
67 | * without having to know those arguments. |
||
68 | * |
||
69 | * @param string $fqcn |
||
70 | * @param string $object_identifier |
||
71 | * @return bool |
||
72 | */ |
||
73 | public function fqcnMatchesObjectIdentifier($fqcn, $object_identifier) |
||
78 | |||
79 | |||
80 | /** |
||
81 | * build a string representation of an object's FQCN and arguments |
||
82 | * |
||
83 | * @param string $fqcn |
||
84 | * @param array $arguments |
||
85 | * @return string |
||
86 | */ |
||
87 | public function getIdentifier($fqcn, array $arguments = array()) |
||
99 | |||
100 | |||
101 | /** |
||
102 | * build a string representation of a object's arguments |
||
103 | * (mostly because Closures can't be serialized) |
||
104 | * |
||
105 | * @param array $arguments |
||
106 | * @return string |
||
107 | */ |
||
108 | protected function getIdentifierForArguments(array $arguments) |
||
130 | } |