Completed
Push — master ( 92472c...fe56a0 )
by Vitaly
02:18
created

Service::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
c 2
b 0
f 1
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: root
5
 * Date: 27.07.2016
6
 * Time: 1:55.
7
 */
8
namespace samsonframework\container\annotation;
9
10
use samsonframework\container\metadata\ClassMetadata;
11
12
/**
13
 * Service annotation class.
14
 *
15
 * This annotation adds class to Service container scope.
16
 * @see samsonframework\container\Container::SCOPE_SERVICE
17
 *
18
 * @Annotation
19
 */
20
class Service extends CollectionValue implements ClassInterface
21
{
22
    /** @var string Service unique name */
23
    protected $name;
24
25
    /**
26
     * Service constructor.
27
     *
28
     * @param string $name Service unique name
29
     *
30
     * @throws \InvalidArgumentException
31
     */
32 1
    public function __construct($name)
33
    {
34 1
        parent::__construct($name);
0 ignored issues
show
Documentation introduced by
$name is of type string, but the function expects a array.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
35
36
        // Get first argument
37 1
        $this->name = array_shift($this->collection);
38 1
    }
39
40
    /** {@inheritdoc} */
41 1
    public function toClassMetadata(ClassMetadata $metadata)
42
    {
43 1
        $metadata->name = $this->name;
44 1
    }
45
}
46