Code Duplication    Length = 17-18 lines in 3 locations

src/services/ModelAccessor.php 1 location

@@ 449-466 (lines=18) @@
446
     * @param string $toScenario
447
     * @return Model[]
448
     */
449
    public function findAllByCriteria($criteria, string $toScenario = null): array
450
    {
451
452
        $models = [];
453
454
        // Find record in db
455
        if ($records = $this->findAllRecordsByCriteria($criteria)
456
        ) {
457
458
            foreach ($records as $record) {
459
                $models[] = $this->findByRecord($record, $toScenario);
460
            }
461
462
        }
463
464
        return $models;
465
466
    }
467
468
    /**
469
     * @param $criteria

src/services/ObjectAccessor.php 2 locations

@@ 364-380 (lines=17) @@
361
     * @param string $toScenario
362
     * @return Object[]
363
     */
364
    public function findAllByCondition($condition, string $toScenario = null): array
365
    {
366
367
        $objects = [];
368
369
        // Find record in db
370
        if ($records = $this->findAllRecordsByCondition($condition)) {
371
372
            foreach ($records as $record) {
373
                $objects[] = $this->findByRecord($record, $toScenario);
374
            }
375
376
        }
377
378
        return $objects;
379
380
    }
381
382
    /**
383
     * @param $condition
@@ 446-463 (lines=18) @@
443
     * @param string $toScenario
444
     * @return Object[]
445
     */
446
    public function findAllByCriteria($criteria, string $toScenario = null): array
447
    {
448
449
        $objects = [];
450
451
        // Find record in db
452
        if ($records = $this->findAllRecordsByCriteria($criteria)
453
        ) {
454
455
            foreach ($records as $record) {
456
                $objects[] = $this->findByRecord($record, $toScenario);
457
            }
458
459
        }
460
461
        return $objects;
462
463
    }
464
465
    /**
466
     * @param $criteria