Code Duplication    Length = 18-24 lines in 2 locations

src/services/traits/ObjectTrait.php 2 locations

@@ 121-138 (lines=18) @@
118
     * @param string $toScenario
119
     * @return Record
120
     */
121
    public function findRecordByCriteria($criteria, string $toScenario = null)
122
    {
123
124
        $query = $this->getRecordQuery($criteria);
125
126
        /** @var Record $record */
127
        if ($record = $query->one()) {
128
129
            // Set scenario
130
            if ($toScenario) {
131
                $record->setScenario($toScenario);
132
            }
133
134
        }
135
136
        return $record;
137
138
    }
139
140
    /**
141
     * @param $condition
@@ 208-231 (lines=24) @@
205
     * @param string $toScenario
206
     * @return Record[]
207
     */
208
    public function findAllRecordsByCriteria($criteria = [], string $toScenario = null)
209
    {
210
211
        $query = $this->getRecordQuery($criteria);
212
213
        /** @var Record[] $record s */
214
        $records = $query->all();
215
216
        // Set scenario
217
        if ($toScenario) {
218
219
            /** @var Record $record */
220
            foreach ($records as $record) {
221
222
                // Set scenario
223
                $record->setScenario($toScenario);
224
225
            }
226
227
        }
228
229
        return $records;
230
231
    }
232
233
234
    /**