![]() Server : Apache System : Linux server2.corals.io 4.18.0-348.2.1.el8_5.x86_64 #1 SMP Mon Nov 15 09:17:08 EST 2021 x86_64 User : corals ( 1002) PHP Version : 7.4.33 Disable Function : exec,passthru,shell_exec,system Directory : /home/corals/old/vendor/magento/framework/Data/ |
<?php /** * Copyright © Magento, Inc. All rights reserved. * See COPYING.txt for license details. */ namespace Magento\Framework\Data; /** * Base Class for simple data Objects * @SuppressWarnings(PHPMD.NumberOfChildren) */ abstract class AbstractDataObject { /** * @var array */ protected $data; /** * Return Data Object data in array format. * * @return array */ public function toArray() { $data = $this->data; $hasToArray = function ($model) { return is_object($model) && method_exists($model, 'toArray') && is_callable([$model, 'toArray']); }; foreach ($data as $key => $value) { if ($hasToArray($value)) { $data[$key] = $value->toArray(); } elseif (is_array($value)) { foreach ($value as $nestedKey => $nestedValue) { if ($hasToArray($nestedValue)) { $value[$nestedKey] = $nestedValue->toArray(); } } $data[$key] = $value; } } return $data; } /** * Retrieves a value from the data array if set, or null otherwise. * * @param string $key * @return mixed|null */ protected function get($key) { return $this->data[$key] ?? null; } }