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

Field   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 21
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 2
c 1
b 0
f 0
lcom 0
cbo 0
dl 0
loc 21
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A byName() 0 8 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