Completed
Push — master ( 348d1d...2a1736 )
by Pol
11:11
created

ResourceValue::doHash()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 0
cts 2
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
declare(strict_types = 1);
4
5
namespace drupol\valuewrapper\Resource;
6
7
use drupol\valuewrapper\AbstractValue;
8
9
abstract class ResourceValue extends AbstractValue
10
{
11
    /**
12
     * ResourceValue constructor.
13
     *
14
     * @param mixed $value
15
     */
16 2
    public function __construct($value)
17
    {
18 2
        if (false == \is_resource($value)) {
0 ignored issues
show
Coding Style Best Practice introduced by
It seems like you are loosely comparing two booleans. Considering using the strict comparison === instead.

When comparing two booleans, it is generally considered safer to use the strict comparison operator.

Loading history...
19
            throw new \TypeError(
20
                'Argument 1 passed to drupol\valuewrapper\Resource\ResourceValue::__construct()' .
0 ignored issues
show
Unused Code introduced by
The call to TypeError::__construct() has too many arguments starting with 'Argument 1 passed to dr...ype($value) . ' given.'.

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
                'must be of the type Resource, ' . gettype($value) . ' given.'
22
            );
23
        }
24
25 2
        parent::__construct($value);
26 2
    }
27
28
    /**
29
     * {@inheritdoc}
30
     */
31
    abstract public function hash(): string;
32
}
33