1 <?php
2
3 /*
4 * This file is part of the ICanBoogie package.
5 *
6 * (c) Olivier Laviale <olivier.laviale@gmail.com>
7 *
8 * For the full copyright and license information, please view the LICENSE
9 * file that was distributed with this source code.
10 */
11
12 namespace ICanBoogie;
13
14 trait ToArrayRecursiveTrait
15 {
16 public function to_array_recursive()
17 {
18 $array = $this->to_array();
19
20 foreach ($array as $key => &$value)
21 {
22 if ($value instanceof ToArrayRecursive)
23 {
24 $value = $value->to_array_recursive();
25 }
26 else if ($value instanceof ToArray)
27 {
28 $value = $value->to_array();
29 }
30 }
31
32 return $array;
33 }
34 }