TestEnhancer::supports()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 9.4285
c 0
b 0
f 0
cc 2
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Psi\Bundle\Description\Example\src;
4
5
use Psi\Component\Description\DescriptionInterface;
6
use Psi\Component\Description\Descriptor\ClassDescriptor;
7
use Psi\Component\Description\Descriptor\StringDescriptor;
8
use Psi\Component\Description\EnhancerInterface;
9
use Psi\Component\Description\Subject;
10
11
class TestEnhancer implements EnhancerInterface
12
{
13
    public function enhanceFromClass(DescriptionInterface $description, \ReflectionClass $class)
14
    {
15
        $description->set('std.class', new ClassDescriptor($class));
16
        $description->set('std.title', new StringDescriptor('Foobar'));
17
    }
18
19
    public function enhanceFromObject(DescriptionInterface $description, Subject $subject)
20
    {
21
        $description->set('example.title', new StringDescriptor($subject->getObject()->title));
22
    }
23
24
    public function supports(Subject $subject)
25
    {
26
        if ($subject->getClass()->getName() !== \stdClass::class) {
0 ignored issues
show
Bug introduced by
Consider using $subject->getClass()->name. There is an issue with getName() and APC-enabled PHP versions.
Loading history...
27
            return false;
28
        }
29
30
        return true;
31
    }
32
}
33