Code Duplication    Length = 35-35 lines in 2 locations

Alpha/Model/ActiveRecordProviderSQLite.php 2 locations

@@ 561-595 (lines=35) @@
558
            $count = 0;
559
            $RecordClass = get_class($this->BO);
560
561
            while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
562
                try {
563
                    $argsCount = count($constructorArgs);
564
565
                    if ($argsCount < 1) {
566
                        $obj = new $RecordClass();
567
                    } else {
568
                        switch ($argsCount) {
569
                            case 1:
570
                                $obj = new $RecordClass($constructorArgs[0]);
571
                                break;
572
                            case 2:
573
                                $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1]);
574
                                break;
575
                            case 3:
576
                                $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2]);
577
                                break;
578
                            case 4:
579
                                $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2], $constructorArgs[3]);
580
                                break;
581
                            case 5:
582
                                $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2], $constructorArgs[3], $constructorArgs[4]);
583
                                break;
584
                            default:
585
                                throw new IllegalArguementException('Too many elements in the $constructorArgs array passed to the loadAllByAttribute method!');
586
                        }
587
                    }
588
589
                    $obj->load($row['OID']);
590
                    $objects[$count] = $obj;
591
                    ++$count;
592
                } catch (ResourceNotAllowedException $e) {
593
                    // the resource not allowed will be absent from the list
594
                }
595
            }
596
597
            $stmt->close();
598
        } else {
@@ 693-727 (lines=35) @@
690
        $count = 0;
691
        $RecordClass = get_class($this->BO);
692
693
        while ($row = $result->fetchArray(SQLITE3_ASSOC)) {
694
            try {
695
                $argsCount = count($constructorArgs);
696
697
                if ($argsCount < 1) {
698
                    $obj = new $RecordClass();
699
                } else {
700
                    switch ($argsCount) {
701
                        case 1:
702
                            $obj = new $RecordClass($constructorArgs[0]);
703
                            break;
704
                        case 2:
705
                            $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1]);
706
                            break;
707
                        case 3:
708
                            $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2]);
709
                            break;
710
                        case 4:
711
                            $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2], $constructorArgs[3]);
712
                            break;
713
                        case 5:
714
                            $obj = new $RecordClass($constructorArgs[0], $constructorArgs[1], $constructorArgs[2], $constructorArgs[3], $constructorArgs[4]);
715
                            break;
716
                        default:
717
                            throw new IllegalArguementException('Too many elements in the $constructorArgs array passed to the loadAllByAttribute method!');
718
                    }
719
                }
720
721
                $obj->load($row['OID']);
722
                $objects[$count] = $obj;
723
                ++$count;
724
            } catch (ResourceNotAllowedException $e) {
725
                // the resource not allowed will be absent from the list
726
            }
727
        }
728
729
        $stmt->close();
730