Code Duplication    Length = 15-19 lines in 4 locations

src/Repository/DbRepository.php 2 locations

@@ 91-105 (lines=15) @@
88
     * 
89
     * @return mixed                Model instance.
90
     */
91
    public function getFirst($conditions = null, $values = [], $options = [])
92
    {
93
        $query = $this->executeQuery(null, $conditions, $values, $options);
94
        if (!empty($this->fetchRefs)) {
95
            $res = $query->fetch();
96
            $model = ($res ? $this->populateModelFromJoin($res) : $res);
97
        } else {
98
            $model = $query->fetchClass($this->modelClass);
99
        }
100
        if ($model && isset($this->manager)) {
101
            $this->manager->manageModel($model);
102
        }
103
        $this->fetchReferences(false);
104
        return $model;
105
    }
106
    
107
    
108
    /**
@@ 117-135 (lines=19) @@
114
     * 
115
     * @return array                Array of all matching entries.
116
     */
117
    public function getAll($conditions = null, $values = [], $options = [])
118
    {
119
        $query = $this->executeQuery(null, $conditions, $values, $options);
120
        if (!empty($this->fetchRefs)) {
121
            $models = [];
122
            foreach ($query->fetchAll() as $model) {
123
                $models[] = $this->populateModelFromJoin($model);
124
            }
125
        } else {
126
            $models = $query->fetchAllClass($this->modelClass);
127
        }
128
        if (isset($this->manager)) {
129
            foreach ($models as $model) {
130
                $this->manager->manageModel($model);
131
            }
132
        }
133
        $this->fetchReferences(false);
134
        return $models;
135
    }
136
    
137
    
138
    /**

src/Repository/SoftDbRepository.php 2 locations

@@ 64-78 (lines=15) @@
61
     * 
62
     * @return mixed                Model instance.
63
     */
64
    public function getFirstSoft($conditions = null, $values = [], $options = [])
65
    {
66
        $query = $this->executeQuerySoft(null, $conditions, $values, $options);
67
        if (!empty($this->fetchRefs)) {
68
            $res = $query->fetch();
69
            $model = ($res ? $this->populateModelFromJoin($res) : $res);
70
        } else {
71
            $model = $query->fetchClass($this->modelClass);
72
        }
73
        if ($model && isset($this->manager)) {
74
            $this->manager->manageModel($model);
75
        }
76
        $this->fetchReferences(false);
77
        return $model;
78
    }
79
    
80
    
81
    /**
@@ 90-108 (lines=19) @@
87
     * 
88
     * @return array                Array of all matching entries.
89
     */
90
    public function getAllSoft($conditions = null, $values = [], $options = [])
91
    {
92
        $query = $this->executeQuerySoft(null, $conditions, $values, $options);
93
        if (!empty($this->fetchRefs)) {
94
            $models = [];
95
            foreach ($query->fetchAll() as $model) {
96
                $models[] = $this->populateModelFromJoin($model);
97
            }
98
        } else {
99
            $models = $query->fetchAllClass($this->modelClass);
100
        }
101
        if (isset($this->manager)) {
102
            foreach ($models as $model) {
103
                $this->manager->manageModel($model);
104
            }
105
        }
106
        $this->fetchReferences(false);
107
        return $models;
108
    }
109
    
110
    
111
    /**