Passed
Pull Request — 4.x (#38)
by Jonathon
10:23
created

ToArrayTrait   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 18
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 9
c 1
b 0
f 0
dl 0
loc 18
rs 10
wmc 3

1 Method

Rating   Name   Duplication   Size   Complexity  
A toArray() 0 16 3
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
                return $entity;
23
            },
24
            $this->data
25
        );
26
    }
27
}
28