Code Duplication    Length = 6-8 lines in 2 locations

src/Entity.php 2 locations

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