Completed
Push — master ( 621ea2...dd23a3 )
by Nick
12s
created

Entity   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 3

Importance

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

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getEntityValue() 0 4 2
A json() 0 8 1
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
use Symfony\Component\Serializer\Encoder\JsonEncoder;
6
use Symfony\Component\Serializer\Normalizer\CustomNormalizer;
7
use Symfony\Component\Serializer\Serializer;
8
9
class Entity extends \ArrayObject
10
{
11
    /**
12
     * @param string                      $key
13
     * @param string|int|float|array|bool $default
14
     *
15
     * @return mixed
16
     */
17
    protected function getEntityValue($key, $default)
18
    {
19
        return isset($this[$key]) ? $this[$key] : $default;
20
    }
21
22
    /**
23
     * Returns the json representation of the current object.
24
     *
25
     * @return string
26
     */
27
    public function json()
28
    {
29
        $encoders = array(new JsonEncoder());
30
        $normalizers = array(new CustomNormalizer());
31
        $serializer = new Serializer($normalizers, $encoders);
32
33
        return $serializer->serialize($this, 'json');
34
    }
35
}
36