1 | <?php |
||
4 | abstract class Builder |
||
5 | { |
||
6 | /** |
||
7 | * Retrive by reflection the constructor arguments from a class. |
||
8 | * The information is statically stored in the function so call two times |
||
9 | * the same class will only run one Reflection |
||
10 | * |
||
11 | * The array is a map of keys as the name of the parameter and value as the |
||
12 | * default value (if any) of the parameter. |
||
13 | * |
||
14 | * The constructor (int $value, array $data = [], $type = 5) returns: |
||
15 | * [ |
||
16 | * 'value' => null, |
||
17 | * 'data' => [], |
||
18 | * 'type' => 5 |
||
19 | * ] |
||
20 | * |
||
21 | * @param string $className |
||
22 | * |
||
23 | * @return array |
||
24 | */ |
||
25 | 15 | public static function retrieveArguments($className) |
|
42 | |||
43 | /** |
||
44 | * Create an instance of a class using the given named parameters |
||
45 | * |
||
46 | * @param string $classname |
||
47 | * @param array $values |
||
48 | * @param array $parameters |
||
49 | * |
||
50 | * @return object |
||
51 | */ |
||
52 | 11 | public static function create($classname, array $values = [], array $parameters = null) |
|
66 | |||
67 | /** |
||
68 | * This function is the same as construct_named_parameters but it convert the case of values and parameters |
||
69 | * Be aware that a constructor can have two parameters with the same name and different case. |
||
70 | * In this situation this function will thow an \InvalidArgumentException |
||
71 | * |
||
72 | * @see create() |
||
73 | * |
||
74 | * @param string $classname |
||
75 | * @param array $values |
||
76 | * @param array|null $parameters |
||
77 | * |
||
78 | * @return object |
||
79 | * |
||
80 | * @throws \InvalidArgumentException if the class has two parameters with the same name but different case |
||
81 | */ |
||
82 | 4 | public static function createIgnoreCase($classname, array $values = [], array $parameters = null) |
|
99 | } |
||
100 |