Completed
Pull Request — master (#4)
by ARCANEDEV
05:31
created

CanBeJsonable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 36
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 100%

Importance

Changes 0
Metric Value
dl 0
loc 36
c 0
b 0
f 0
wmc 2
lcom 0
cbo 0
ccs 4
cts 4
cp 1
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toJson() 0 4 1
A jsonSerialize() 0 4 1
toArray() 0 1 ?
1
<?php namespace Arcanedev\GeoLocation\Traits;
2
3
/**
4
 * Trait     JsonableEntity
5
 *
6
 * @package  Arcanedev\GeoLocation\Traits
7
 * @author   ARCANEDEV <[email protected]>
8
 */
9
trait CanBeJsonable
10
{
11
    /* -----------------------------------------------------------------
12
     |  Main Methods
13
     | -----------------------------------------------------------------
14
     */
15
16
    /**
17
     * Convert the object to its JSON representation.
18
     *
19
     * @param  int  $options
20
     *
21
     * @return string
22
     */
23 21
    public function toJson($options = 0)
24
    {
25 21
        return json_encode($this->jsonSerialize(), $options);
26
    }
27
28
    /**
29
     * Convert the object into something JSON serializable.
30
     *
31
     * @return array
32
     */
33 21
    public function jsonSerialize()
34
    {
35 21
        return $this->toArray();
36
    }
37
38
    /**
39
     * Get the instance as an array.
40
     *
41
     * @return array
42
     */
43
    abstract public function toArray();
44
}
45