Code Duplication    Length = 6-8 lines in 2 locations

src/Entity.php 2 locations

@@ 63-70 (lines=8) @@
60
    public function toArray($recursive = false)
61
    {
62
        $array = [];
63
        foreach (array_keys($this->data) as $key) {
64
            $array[$key] = $this->__get($key);
65
            if ($array[$key] instanceof Contracts\Entity) {
66
                if ($recursive) {
67
                    $array[$key] = $array[$key]->toArray(true);
68
                }
69
            }
70
        }
71
72
        return $array;
73
    }
@@ 78-83 (lines=6) @@
75
    public function getData()
76
    {
77
        $data = [];
78
        foreach (array_keys($this->data) as $key) {
79
            $data[$key] = $this->__get($key);
80
            if ($data[$key] instanceof Contracts\Entity) {
81
                $data[$key] = $data[$key]->id;
82
            }
83
        }
84
85
        return $data;
86
    }