Completed
Push — master ( 6751ec...bd2805 )
by JHONATAN
03:37
created

MetadataTrait::getClassMetadata()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 11
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.0416

Importance

Changes 0
Metric Value
dl 0
loc 11
ccs 5
cts 6
cp 0.8333
rs 9.4285
c 0
b 0
f 0
cc 3
eloc 5
nc 4
nop 1
crap 3.0416
1
<?php
2
3
namespace Vox\Webservice;
4
5
use Metadata\MetadataFactoryInterface;
6
use Vox\Webservice\Metadata\TransferMetadata;
7
8
/**
9
 * some metadata utilities
10
 * 
11
 * @author Jhonatan Teixeira <[email protected]>
12
 */
13
trait MetadataTrait
14
{
15
     /**
16
     * @var MetadataFactoryInterface
17
     */
18
    private $metadataFactory;
19
    
20 13
    private function getIdValue($object)
21
    {
22 13
        return $this->getClassMetadata($object)->id->getValue($object);
23
    }
24
    
25 13
    private function getClassMetadata($object): TransferMetadata
26
    {
27 13
        if ($object instanceof AccessInterceptorValueHolderInterface) {
0 ignored issues
show
Bug introduced by
The type Vox\Webservice\AccessInt...torValueHolderInterface was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
28
            $object = $object->getWrappedValueHolderValue();
29
        }
30
31 13
        if (is_object($object)) {
32 13
            $object = get_class($object);
33
        }
34
35 13
        return $this->metadataFactory->getMetadataForClass($object);
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this->metadataFa...tadataForClass($object) returns the type null|Metadata\ClassHierarchyMetadata which is incompatible with the type-hinted return Vox\Webservice\Metadata\TransferMetadata.
Loading history...
36
    }
37
}
38