Code Duplication    Length = 18-18 lines in 2 locations

system/Inji/Model.php 2 locations

@@ 737-754 (lines=18) @@
734
            $query->join($join[0], $join[1]);
735
        }
736
        static::$relJoins = [];
737
        foreach (static::$needJoin as $rel) {
738
            $relations = static::relations();
739
            if (isset($relations[$rel])) {
740
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
741
                switch ($type) {
742
                    case 'to':
743
                        $relCol = $relations[$rel]['col'];
744
                        static::fixPrefix($relCol);
745
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
746
                        break;
747
                    case 'one':
748
                        $col = $relations[$rel]['col'];
749
                        $relations[$rel]['model']::fixPrefix($col);
750
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
751
                        break;
752
                }
753
            }
754
        }
755
        static::$needJoin = [];
756
757
        if (!empty($options['limit']))
@@ 1048-1065 (lines=18) @@
1045
            $query->join($join[0], $join[1]);
1046
        }
1047
        static::$relJoins = [];
1048
        foreach (static::$needJoin as $rel) {
1049
            $relations = static::relations();
1050
            if (isset($relations[$rel])) {
1051
                $type = empty($relations[$rel]['type']) ? 'to' : $relations[$rel]['type'];
1052
                switch ($type) {
1053
                    case 'to':
1054
                        $relCol = $relations[$rel]['col'];
1055
                        static::fixPrefix($relCol);
1056
                        $query->join($relations[$rel]['model']::table(), $relations[$rel]['model']::index() . ' = ' . $relCol);
1057
                        break;
1058
                    case 'one':
1059
                        $col = $relations[$rel]['col'];
1060
                        $relations[$rel]['model']::fixPrefix($col);
1061
                        $query->join($relations[$rel]['model']::table(), static::index() . ' = ' . $col);
1062
                        break;
1063
                }
1064
            }
1065
        }
1066
        static::$needJoin = [];
1067
        $cols = 'COUNT(';
1068