Completed
Push — master ( 692093...daa27a )
by Vitaly
02:57
created

Service::toClassMetadata()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 1

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 5
ccs 4
cts 4
cp 1
rs 9.4285
cc 1
eloc 3
nc 1
nop 1
crap 1
1
<?php declare(strict_types = 1);
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\configurator\ServiceConfigurator;
11
12
/**
13
 * Service configurator annotation class.
14
 * @see    \samsonframework\container\configurator\ServiceConfigurator
15
 *
16
 * @author Vitaly Egorov <[email protected]>
17
 *
18
 * @Annotation
19
 */
20
class Service extends ServiceConfigurator
21
{
22
    use AnnotationValueTrait;
23
24
    /**
25
     * Service constructor.
26
     *
27
     * @param string|array $valueOrValues Service unique name
28
     *
29
     * @throws \InvalidArgumentException
30
     */
31 3
    public function __construct($valueOrValues)
32
    {
33
        // Parse annotation value and pass to configurator
34 3
        parent::__construct($this->parseAnnotationValue($valueOrValues));
0 ignored issues
show
Bug introduced by
It seems like $valueOrValues defined by parameter $valueOrValues on line 31 can also be of type string; however, samsonframework\containe...:parseAnnotationValue() does only seem to accept array, maybe add an additional type check?

This check looks at variables that have been passed in as parameters and are passed out again to other methods.

If the outgoing method call has stricter type requirements than the method itself, an issue is raised.

An additional type check may prevent trouble.

Loading history...
Documentation introduced by
$this->parseAnnotationValue($valueOrValues) is of type array, but the function expects a string.

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
}
37