1 | <?php |
||
49 | class ConvertToArray |
||
50 | { |
||
51 | /** |
||
52 | * convert a piece of data to be a real PHP array |
||
53 | * |
||
54 | * @param mixed $data |
||
55 | * the data to convert |
||
56 | * @return array |
||
57 | */ |
||
58 | public function __invoke($data) |
||
62 | |||
63 | /** |
||
64 | * convert a piece of data to be a real PHP array |
||
65 | * |
||
66 | * @param mixed $data |
||
67 | * the data to convert |
||
68 | * @return array |
||
69 | */ |
||
70 | public static function from($data) |
||
75 | |||
76 | /** |
||
77 | * convert a piece of data to be a real PHP array |
||
78 | * |
||
79 | * @param array $data |
||
80 | * the data to convert |
||
81 | * @return array |
||
82 | */ |
||
83 | private static function fromArray($data) |
||
88 | |||
89 | /** |
||
90 | * convert a piece of data to be a real PHP array |
||
91 | * |
||
92 | * @param null $data |
||
93 | * the data to convert |
||
94 | * @return array |
||
95 | */ |
||
96 | private static function fromNull($data) |
||
101 | |||
102 | /** |
||
103 | * convert a piece of data to be a real PHP array |
||
104 | * |
||
105 | * @param Traversable $data |
||
106 | * the data to convert |
||
107 | * @return array |
||
108 | */ |
||
109 | private static function fromTraversable($data) |
||
122 | |||
123 | /** |
||
124 | * convert a piece of data to be a real PHP array |
||
125 | * |
||
126 | * @param mixed $data |
||
127 | * the data to convert |
||
128 | * @return array |
||
129 | */ |
||
130 | private static function nothingMatchesTheInputType($data) |
||
134 | |||
135 | /** |
||
136 | * lookup map of how to convert which data type |
||
137 | * |
||
138 | * @var array |
||
139 | */ |
||
140 | private static $dispatchMap = [ |
||
141 | 'Array' => 'fromArray', |
||
142 | 'NULL' => 'fromNull', |
||
143 | 'Traversable' => 'fromTraversable' |
||
144 | ]; |
||
145 | } |
||
146 |
This check looks from parameters that have been defined for a function or method, but which are not used in the method body.