NamedConstructorsTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 20
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 20
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A fromTraversable() 0 4 1
A fromArray() 0 4 1
1
<?php
2
3
namespace Shrikeh\Collection;
4
5
use ArrayObject;
6
use Traversable;
7
8
/**
9
 * Trait NamedConstructorsTrait
10
 * @package Shrikeh\Collection
11
 */
12
trait NamedConstructorsTrait
13
{
14
    /**
15
     * @param Traversable $traversable
16
     * @return static
17
     */
18
    public static function fromTraversable(Traversable $traversable)
19
    {
20
        return new static($traversable);
0 ignored issues
show
Unused Code introduced by
The call to NamedConstructorsTrait::__construct() has too many arguments starting with $traversable.

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
21
    }
22
23
    /**
24
     * @param array $objects
25
     * @return static
26
     */
27
    public static function fromArray(array $objects = array())
28
    {
29
        return new static(new ArrayObject($objects));
0 ignored issues
show
Unused Code introduced by
The call to NamedConstructorsTrait::__construct() has too many arguments starting with new \ArrayObject($objects).

This check compares calls to functions or methods with their respective definitions. If the call has more arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress.

In this case you can add the @ignore PhpDoc annotation to the duplicate definition and it will be ignored.

Loading history...
30
    }
31
}
32