Completed
Push — master ( 90ccc1...22512f )
by Kamil
35:43
created

MetadataContainer   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 32
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 32
rs 10
c 1
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getMetadata() 0 8 3
A setMetadata() 0 4 1
A serializeMetadata() 0 4 1
1
<?php
2
3
namespace Sylius\Bundle\MetadataBundle\Model;
4
5
use Sylius\Component\Metadata\Model\MetadataInterface;
6
use Sylius\Component\Metadata\Model\MetadataContainer as BaseMetadataContainer;
7
use Sylius\Component\Metadata\Model\MetadataContainerInterface;
8
9
/**
10
 * @author Kamil Kokot <[email protected]>
11
 */
12
class MetadataContainer extends BaseMetadataContainer implements MetadataContainerInterface
13
{
14
    /**
15
     * @var MetadataInterface
16
     */
17
    protected $metadataAsObject;
18
19
    /**
20
     * {@inheritdoc}
21
     */
22
    public function getMetadata()
23
    {
24
        if (null !== $this->metadataAsObject) {
25
            return $this->metadataAsObject;
26
        }
27
28
        return unserialize($this->metadata) ?: null;
29
    }
30
31
    /**
32
     * {@inheritdoc}
33
     */
34
    public function setMetadata(MetadataInterface $metadata)
35
    {
36
        $this->metadataAsObject = $metadata;
37
    }
38
39
    public function serializeMetadata()
40
    {
41
        $this->metadata = serialize($this->metadataAsObject);
0 ignored issues
show
Documentation Bug introduced by
It seems like serialize($this->metadataAsObject) of type string is incompatible with the declared type object<Sylius\Component\...odel\MetadataInterface> of property $metadata.

Our type inference engine has found an assignment to a property that is incompatible with the declared type of that property.

Either this assignment is in error or the assigned type should be added to the documentation/type hint for that property..

Loading history...
42
    }
43
}
44