ObjectOptions::options()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 8
rs 9.4285
cc 3
eloc 4
nc 2
nop 1
1
<?php
2
3
namespace Iatstuti\SimpleMenu\Traits;
4
5
/**
6
 * Trait to handle retrieving all or a specific option.
7
 *
8
 * @package    Iatstuti\SimpleMenu
9
 * @copyright  2016 IATSTUTI
10
 * @author     Michael Dyrynda <[email protected]>
11
 */
12
trait ObjectOptions
13
{
14
15
    /**
16
     * Return this menu's options, or a single option as specified.
17
     *
18
     * @param  string|null $key
19
     *
20
     * @return array
21
     */
22
    public function options($key = null)
23
    {
24
        if (! is_null($key) && array_key_exists($key, $this->options)) {
25
            return $this->options[$key];
26
        }
27
28
        return $this->options;
29
    }
30
31
}
32