Completed
Push — master ( c2add9...d388c3 )
by ARCANEDEV
14s
created

CanBeJsonable::jsonSerialize()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
c 0
b 0
f 0
ccs 2
cts 2
cp 1
rs 10
cc 1
eloc 2
nc 1
nop 0
crap 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