Code Duplication    Length = 12-15 lines in 2 locations

src/Field.php 1 location

@@ 45-56 (lines=12) @@
42
     * @param self $return Variable to return found database record
43
     * @return bool|null|self  Field instance or null if 3rd parameter not passed
44
     */
45
    public static function byNameOrID(QueryInterface $query, $nameOrID, self & $return = null)
46
    {
47
        // Create id or URL condition
48
        $idOrUrl = new Condition('OR');
49
        $idOrUrl->add('FieldID', $nameOrID)->add('Name', $nameOrID);
50
51
        // Perform query
52
        $return = $query->entity(get_called_class())->where($idOrUrl)->first();
53
54
        // If only one argument is passed - return null, otherwise bool
55
        return func_num_args() > 1 ? $return == null : $return;
56
    }
57
58
    /** @return string Get additional field value field name depending on its type */
59
    public function valueFieldName()

src/Material.php 1 location

@@ 143-157 (lines=15) @@
140
     * @return bool|self[] True if material entities has been found and $return is passed
141
     *                      or self[] if only two parameters is passed.
142
     */
143
    public static function byNavigationID(QueryInterface $query, $navigationID, &$return = array())
144
    {
145
        /** @var array $materialIds Collection of entity identifiers filtered by additional field */
146
        $materialIds = null;
147
        if (static::idsByNavigationID($query, $navigationID, $materialIds)) {
148
            $return = $query->entity(get_called_class())
149
                ->where('MaterialID', $materialIds)
150
                ->where('Active', 1)
151
                ->where('Published', 1)
152
                ->exec();
153
        }
154
155
        // If only one argument is passed - return null, otherwise bool
156
        return func_num_args() > 2 ? $return == null : $return;
157
    }
158
159
    /**
160
     * Get current entity instances collection by navigation identifier.