Completed
Push — master ( 8b858f...e8b42a )
by Randy
05:29
created

Hydrate::assignValue()   A

Complexity

Conditions 4
Paths 3

Size

Total Lines 15
Code Lines 8

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4

Importance

Changes 0
Metric Value
dl 0
loc 15
ccs 7
cts 7
cp 1
rs 9.2
c 0
b 0
f 0
cc 4
eloc 8
nc 3
nop 2
crap 4
1
<?php
2
3
namespace Dgame\Soap\Hydrator;
4
5
use Dgame\Object\ObjectFacade;
6
use Dgame\Soap\AssignableInterface;
7
8
/**
9
 * Class Hydrate
10
 * @package Dgame\Soap\Hydrator
11
 */
12
final class Hydrate extends ObjectFacade
13
{
14
    /**
15
     * @param string $class
16
     *
17
     * @return Hydrate
0 ignored issues
show
Documentation introduced by
Should the return type not be \self?

This check compares the return type specified in the @return annotation of a function or method doc comment with the types returned by the function and raises an issue if they mismatch.

Loading history...
18
     */
19 6
    public static function new(string $class): self
20
    {
21 6
        return new self(new $class());
22
    }
23
24
    /**
25
     * @param Hydrate $hydrat
0 ignored issues
show
Documentation introduced by
Should the type for parameter $hydrat not be \self?

This check looks for @param annotations where the type inferred by our type inference engine differs from the declared type.

It makes a suggestion as to what type it considers more descriptive.

Most often this is a case of a parameter that can be null in addition to its declared types.

Loading history...
26
     */
27 4
    public function append(self $hydrat)
28
    {
29 4
        $this->setValue($hydrat->getClassName(), $hydrat->getObject());
30 4
    }
31
32
    /**
33
     * @param AssignableInterface $assignable
34
     */
35 6
    public function assign(AssignableInterface $assignable)
36
    {
37 6
        if ($assignable->hasValue()) {
38 6
            $this->setValue($assignable->getName(), $assignable->getValue());
39
        }
40 6
    }
41
42
    /**
43
     * @return string
44
     */
45 4
    public function getClassName(): string
46
    {
47 4
        return $this->getReflection()->getShortName();
48
    }
49
}