Visibility::getCondition()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 0
crap 1
1
<?php
2
3
namespace Acquia\LiftClient\Entity;
4
5
use Acquia\LiftClient\Exception\LiftSdkException;
6
use Acquia\LiftClient\Utility\Utility;
7
8
class Visibility extends Entity
9
{
10
    /**
11
     * @param array $array
12
     */
13 30
    public function __construct(array $array = [])
14
    {
15 30
        parent::__construct($array);
16 30
    }
17
18
    /**
19
     * @param array $pages Specify pages by using their paths. The '*' character
20
     *                     is a wildcard. Example paths are
21
     *                     http://mywebsite.com/user for the current user's page
22
     *                     and http://mywebsite.com/user/* for every user page
23
     *
24
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
25
     *
26
     * @return \Acquia\LiftClient\Entity\Visibility
27
     */
28 15
    public function setPages(array $pages = [])
29
    {
30 15
        if (Utility::arrayDepth($pages) > 1) {
31 3
            throw new LiftSdkException('Pages argument is more than 1 level deep.');
32
        }
33
34 12
        $this['pages'] = $pages;
35
36 12
        return $this;
37
    }
38
39
    /**
40
     * Gets the 'pages' parameter.
41
     *
42
     * @return array
43
     */
44 15
    public function getPages()
45
    {
46 15
        return $this->getEntityValue('pages', '');
47
    }
48
49
    /**
50
     * @param string $condition Can be 'show' or 'hide'. Any other option will
51
     *                          be ignored
52
     *
53
     * @throws \Acquia\LiftClient\Exception\LiftSdkException
54
     *
55
     * @return \Acquia\LiftClient\Entity\Visibility
56
     */
57 18
    public function setCondition($condition)
58
    {
59 18
        if (!is_string($condition)) {
60 3
            throw new LiftSdkException('Argument must be an instance of string.');
61
        }
62
63 15
        if ($condition !== 'show' && $condition !== 'hide') {
64 3
            throw new LiftSdkException('Status much be either show or hide.');
65
        }
66 12
        $this['condition'] = $condition;
67
68 12
        return $this;
69
    }
70
71
    /**
72
     * Gets the 'condition' parameter.
73
     *
74
     * @return array
75
     */
76 15
    public function getCondition()
77
    {
78 15
        return $this->getEntityValue('condition', '');
79
    }
80
}
81