Completed
Push — master ( ad3f3f...b283b6 )
by Randy
02:33
created

Hydrate::getClassName()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 0
crap 1
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
     * @return bool
28
     */
29 4
    public function append(self $hydrat): bool
30
    {
31 4
        return $this->setValue($hydrat->getClassName(), $hydrat->getObject());
32
    }
33
34
    /**
35
     * @param AssignableInterface $assignable
36
     *
37
     * @return bool
38
     */
39 6
    public function assign(AssignableInterface $assignable): bool
40
    {
41 6
        if ($assignable->hasValue()) {
42 6
            return $this->setValue($assignable->getName(), $assignable->getValue());
43
        }
44
45 1
        return false;
46
    }
47
48
    /**
49
     * @return string
50
     */
51 4
    public function getClassName(): string
52
    {
53 4
        return $this->getReflection()->getShortName();
54
    }
55
}