Code Duplication    Length = 12-16 lines in 2 locations

src/Field.php 1 location

@@ 42-53 (lines=12) @@
39
     * @param self $return Variable to return found database record
40
     * @return bool|null|self  Field instance or null if 3rd parameter not passed
41
     */
42
    public static function byNameOrID(QueryInterface $query, $nameOrID, self & $return = null)
43
    {
44
        // Create id or URL condition
45
        $idOrUrl = new Condition('OR');
46
        $idOrUrl->add('FieldID', $nameOrID)->add('Name', $field);
47
48
        // Perform query
49
        $return = $query->className('field')->cond($idOrUrl)->first();
50
51
        // If only one argument is passed - return null, otherwise bool
52
        return func_num_args() > 1 ? $return == null : $return;
53
    }
54
}
55

src/MaterialField.php 1 location

@@ 24-39 (lines=16) @@
21
     * @param string $locale Locale identifier
22
     * @return bool|null|self  Field instance or null if 3rd parameter not passed
23
     */
24
    public static function byFieldIDAndMaterialID(
25
        QueryInterface $query,
26
        $materialID,
27
        $fieldID,
28
        self & $return = null,
29
        $locale = DEFAULT_LOCALE
30
    ) {
31
        $return = $query->className(__CLASS__)
32
            ->cond('MaterialID', $materialID)
33
            ->cond('FieldID', $fieldID)
34
            ->cond('locale', $locale)
35
            ->first();
36
37
        // If only one argument is passed - return null, otherwise bool
38
        return func_num_args() > 1 ? $return == null : $return;
39
    }
40
}
41