Code Duplication    Length = 18-24 lines in 2 locations

src/behaviors/ObjectRecordAccessor.php 2 locations

@@ 143-160 (lines=18) @@
140
     * @param string $toScenario
141
     * @return Record
142
     */
143
    public function findRecordByCriteria($criteria, string $toScenario = null)
144
    {
145
146
        $query = $this->getRecordQuery($criteria);
147
148
        /** @var Record $record */
149
        if ($record = $query->one()) {
150
151
            // Set scenario
152
            if ($toScenario) {
153
                $record->setScenario($toScenario);
154
            }
155
156
        }
157
158
        return $record;
159
160
    }
161
162
    /**
163
     * @param $condition
@@ 230-253 (lines=24) @@
227
     * @param string $toScenario
228
     * @return Record[]
229
     */
230
    public function findAllRecordsByCriteria($criteria = [], string $toScenario = null)
231
    {
232
233
        $query = $this->getRecordQuery($criteria);
234
235
        /** @var Record[] $record s */
236
        $records = $query->all();
237
238
        // Set scenario
239
        if ($toScenario) {
240
241
            /** @var Record $record */
242
            foreach ($records as $record) {
243
244
                // Set scenario
245
                $record->setScenario($toScenario);
246
247
            }
248
249
        }
250
251
        return $records;
252
253
    }
254
255
256
    /**