ToArrayTrait   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 11
c 2
b 0
f 0
dl 0
loc 22
rs 10
wmc 4

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 20 4
1
<?php
2
3
namespace Aura\Marshal;
4
5
use Aura\Marshal\Lazy\GenericLazy;
6
7
trait ToArrayTrait
8
{
9
    public function toArray(): array
10
    {
11
        return array_map(
12
            function ($entity)
13
            {
14
                if ($entity instanceof GenericLazy) {
15
                    $entity = $entity->get($this);
16
                }
17
18
                if ($entity instanceof ToArrayInterface) {
19
                    return $entity->toArray();
20
                }
21
22
                if (is_object($entity)) {
23
                    return (array) $entity;
24
                }
25
26
                return $entity;
27
            },
28
            $this->data
29
        );
30
    }
31
}
32