Completed
Push — master ( 7e3e80...db00dc )
by Vitaly
02:47
created

Field::byID()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 3

Duplication

Lines 8
Ratio 100 %
Metric Value
dl 8
loc 8
rs 9.4286
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
namespace samsoncms\api;
3
4
use samsonframework\orm\QueryInterface;
5
6
/**
7
 * SamsonCMS additional field table entity class
8
 * @package samson\cms
9
 */
10
class Field extends \samson\activerecord\field
11
{
12
    /**
13
     * Find additional field database record by Name.
14
     * This is generic method that should be used in nested classes to find its
15
     * records by some its primary key value.
16
     *
17
     * @param QueryInterface $query Query object instance
18
     * @param string $name Additional field name
19
     * @param self $return Variable to return found database record
20
     * @return bool|null|self  Field instance or null if 3rd parameter not passed
21
     */
22
    public static function byName(QueryInterface $query, $name, self & $return = null)
23
    {
24
        // Get field record by name column
25
        $return = static::oneByColumn($query, 'Name', $name);
26
27
        // If only one argument is passed - return null, otherwise bool
28
        return func_num_args() > 1 ? $return == null : $return;
29
    }
30
}
31