1 | <?php |
||
16 | class ObjectIdentifier |
||
17 | { |
||
18 | |||
19 | /** |
||
20 | * used to separate the FQCN from the class's arguments identifier |
||
21 | */ |
||
22 | const DELIMITER = '____'; |
||
23 | |||
24 | /** |
||
25 | * @var ClassInterfaceCache $class_cache |
||
26 | */ |
||
27 | private $class_cache; |
||
28 | |||
29 | |||
30 | /** |
||
31 | * ObjectIdentifier constructor. |
||
32 | * |
||
33 | * @param ClassInterfaceCache $class_cache |
||
34 | */ |
||
35 | public function __construct(ClassInterfaceCache $class_cache) |
||
39 | |||
40 | |||
41 | /** |
||
42 | * Returns true if the supplied $object_identifier contains |
||
43 | * the delimiter used to separate an fqcn from the arguments hash |
||
44 | * |
||
45 | * @param string $object_identifier |
||
46 | * @return bool |
||
47 | */ |
||
48 | public function hasArguments($object_identifier) |
||
55 | |||
56 | |||
57 | /** |
||
58 | * Returns true if the supplied FQCN equals the supplied $object_identifier |
||
59 | * OR the supplied FQCN matches the FQCN portion of the supplied $object_identifier |
||
60 | * AND that $object_identifier is for an object with arguments. |
||
61 | * This allows a request for an object using a FQCN to match |
||
62 | * a previously instantiated object with arguments |
||
63 | * without having to know those arguments. |
||
64 | * |
||
65 | * @param string $fqcn |
||
66 | * @param string $object_identifier |
||
67 | * @return bool |
||
68 | */ |
||
69 | public function fqcnMatchesObjectIdentifier($fqcn, $object_identifier) |
||
74 | |||
75 | |||
76 | /** |
||
77 | * build a string representation of an object's FQCN and arguments |
||
78 | * |
||
79 | * @param string $fqcn |
||
80 | * @param array $arguments |
||
81 | * @return string |
||
82 | */ |
||
83 | public function getIdentifier($fqcn, array $arguments = array()) |
||
97 | |||
98 | |||
99 | /** |
||
100 | * build a string representation of a object's arguments |
||
101 | * (mostly because Closures can't be serialized) |
||
102 | * |
||
103 | * @param array $arguments |
||
104 | * @return string |
||
105 | */ |
||
106 | protected function getIdentifierForArguments(array $arguments) |
||
128 | } |
||
129 |