Completed
Push — master ( 5cacfc...b3211d )
by Nick
51s
created

Visibility::setCondition()   A

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 Acquia\LiftClient\Entity;
4
5
class Visibility extends \ArrayObject
6
{
7
    /**
8
     * @param array $array
9
     */
10
    public function __construct(array $array = [])
11
    {
12
        parent::__construct($array);
13
    }
14
15
    /**
16
     * @param array $pages
17
     *   Specify pages by using their paths. The '*' character is a wildcard.
18
     *   Example paths are http://mywebsite.com/user for the current user's page
19
     *   and http://mywebsite.com/user/* for every user page.
20
     *
21
     * @return \Acquia\LiftClient\Entity\Visibility
22
     */
23
    public function setPages(array $pages = [])
24
    {
25
        $this['pages'] = $pages;
26
27
        return $this;
28
    }
29
30
    /**
31
     * Gets the 'pages' parameter.
32
     *
33
     * @return array
34
     */
35
    public function getPages()
36
    {
37
        return $this->getValue('pages', '');
38
    }
39
40
    /**
41
     * @param string $condition
42
     *   Sets the condition of this visibility object. Can be 'show' or 'hide'.
43
     *   Any other option will be ignored.
44
     *
45
     * @return \Acquia\LiftClient\Entity\Visibility
46
     */
47
    public function setCondition($condition)
48
    {
49
        if ($condition === 'show' || $condition === 'hide') {
50
            $this['condition'] = $condition;
51
        }
52
53
        return $this;
54
    }
55
56
    /**
57
     * Gets the 'condition' parameter.
58
     *
59
     * @return array
60
     */
61
    public function getCondition()
62
    {
63
        return $this->getValue('condition', '');
64
    }
65
66
    /**
67
     *
68
     * @param string $key
69
     * @param string $default
70
     *
71
     * @return mixed
72
     */
73
    protected function getValue($key, $default)
74
    {
75
        return isset($this[$key]) ? $this[$key] : $default;
76
    }
77
}
78