Completed
Push — master ( 53e339...a17e2b )
by Travis
04:37
created

Link::toJson()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
nc 1
nop 1
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
3
namespace JumpGate\Menu;
4
5
use Illuminate\Contracts\Support\Jsonable;
6
use JumpGate\Menu\Traits\Activate;
7
use JumpGate\Menu\Traits\Insertable;
8
9
/**
10
 * Class Link
11
 *
12
 * @package JumpGate\Menu
13
 */
14
class Link implements Jsonable
15
{
16
    use Activate, Insertable;
17
18
    /**
19
     * The link slug
20
     *
21
     * @var string
22
     */
23
    public $slug;
24
25
    /**
26
     * Name of the link
27
     *
28
     * @var string
29
     */
30
    public $name;
31
32
    /**
33
     * Link url
34
     *
35
     * @var string
36
     */
37
    public $url;
38
39
    /**
40
     * Additional options for links
41
     *
42
     * @var array
43
     */
44
    public $options = [];
45
46
    /**
47
     * Get a menu option
48
     *
49
     * @param $name The name of the menu option
50
     *
51
     * @return string|bool Return the menu option if it exists or false.
52
     */
53
    public function getOption($name)
54
    {
55
        if (isset($this->options[$name])) {
56
            return $this->options[$name];
57
        }
58
59
        return false;
60
    }
61
62
    /**
63
     * Check if the current object is a drop down
64
     *
65
     * @return bool
66
     */
67
    public function isDropDown()
68
    {
69
        return false;
70
    }
71
72
    /**
73
     * Convert link to JSON.
74
     * 
75
     * @param int $options
76
     *
77
     * @return string
78
     */
79
    public function toJson($options = 0)
80
    {
81
        $properties = get_object_vars($this);
82
        unset($properties['menu']);
83
84
        return json_encode($properties);
85
    }
86
}
87