IntegerDefinition   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 12
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A instantiateNode() 0 4 1
1
<?php
2
/*
3
 * This file is part of the Borobudur-Config package.
4
 *
5
 * (c) Hexacodelabs <http://hexacodelabs.com>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
namespace Borobudur\Config\Definition\Builder;
12
13
use Borobudur\Config\Definition\IntegerNode;
14
15
/**
16
 * @author      Iqbal Maulana <[email protected]>
17
 * @created     8/10/15
18
 */
19
class IntegerDefinition extends AbstractNumericDefinition
20
{
21
    /**
22
     * Instantiate integer node.
23
     *
24
     * @return IntegerNode
25
     */
26
    protected function instantiateNode()
27
    {
28
        return new IntegerNode($this->name, $this->parent, $this->min, $this->max);
0 ignored issues
show
Bug introduced by
It seems like $this->parent can also be of type object<Borobudur\Config\...er\DefinitionInterface> or object<Borobudur\Config\...odeDefinitionInterface>; however, Borobudur\Config\Definit...ericNode::__construct() does only seem to accept null|object<Borobudur\Co...finition\NodeInterface>, maybe add an additional type check?

If a method or function can return multiple different values and unless you are sure that you only can receive a single value in this context, we recommend to add an additional type check:

/**
 * @return array|string
 */
function returnsDifferentValues($x) {
    if ($x) {
        return 'foo';
    }

    return array();
}

$x = returnsDifferentValues($y);
if (is_array($x)) {
    // $x is an array.
}

If this a common case that PHP Analyzer should handle natively, please let us know by opening an issue.

Loading history...
29
    }
30
}
31