Completed
Push — develop ( def468...bd7545 )
by Franck
7s
created

PresentationProperties::setCommentVisible()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 4
cts 4
cp 1
rs 9.4285
cc 2
eloc 4
nc 2
nop 1
crap 2
1
<?php
2
/**
3
 * This file is part of PHPPresentation - A pure PHP library for reading and writing
4
 * presentations documents.
5
 *
6
 * PHPPresentation is free software distributed under the terms of the GNU Lesser
7
 * General Public License version 3 as published by the Free Software Foundation.
8
 *
9
 * For the full copyright and license information, please read the LICENSE
10
 * file that was distributed with this source code. For the full list of
11
 * contributors, visit https://github.com/PHPOffice/PHPPresentation/contributors.
12
 *
13
 * @link        https://github.com/PHPOffice/PHPPresentation
14
 * @copyright   2009-2015 PHPPresentation contributors
15
 * @license     http://www.gnu.org/licenses/lgpl.txt LGPL version 3
16
 */
17
namespace PhpOffice\PhpPresentation;
18
19
/**
20
 * \PhpOffice\PhpPresentation\PresentationProperties
21
 */
22
class PresentationProperties
23
{
24
    const VIEW_HANDOUT = 'handoutView';
25
    const VIEW_NOTES = 'notesView';
26
    const VIEW_NOTES_MASTER = 'notesMasterView';
27
    const VIEW_OUTLINE = 'outlineView';
28
    const VIEW_SLIDE = 'sldView';
29
    const VIEW_SLIDE_MASTER = 'sldMasterView';
30
    const VIEW_SLIDE_SORTER = 'sldSorterView';
31
    const VIEW_SLIDE_THUMBNAIL = 'sldThumbnailView';
32
33
    protected $arrayView = array(
34
        self::VIEW_HANDOUT,
35
        self::VIEW_NOTES,
36
        self::VIEW_NOTES_MASTER,
37
        self::VIEW_OUTLINE,
38
        self::VIEW_SLIDE,
39
        self::VIEW_SLIDE_MASTER,
40
        self::VIEW_SLIDE_SORTER,
41
        self::VIEW_SLIDE_THUMBNAIL,
42
    );
43
44
    /*
45
     * @var boolean
46
     */
47
    protected $isLoopUntilEsc = false;
48
49
    /**
50
     * Mark as final
51
     * @var bool
52
     */
53
    protected $markAsFinal = false;
54
55
    /*
56
     * @var string
57
     */
58
    protected $thumbnail;
59
60
    /**
61
     * Zoom
62
     * @var float
63
     */
64
    protected $zoom = 1;
65
66
    /*
67
     * @var boolean
68
     */
69
    protected $lastView = self::VIEW_SLIDE;
70
71
    /*
72
     * @var boolean
73
     */
74
    protected $isCommentVisible = false;
75
    
76
    /**
77
     * @return bool
78
     */
79 150
    public function isLoopContinuouslyUntilEsc()
80
    {
81 150
        return $this->isLoopUntilEsc;
82
    }
83
    
84
    /**
85
     * @param bool $value
86
     * @return \PhpOffice\PhpPresentation\PresentationProperties
87
     */
88 2
    public function setLoopContinuouslyUntilEsc($value = false)
89
    {
90 2
        if (is_bool($value)) {
91 2
            $this->isLoopUntilEsc = $value;
92
        }
93 2
        return $this;
94
    }
95
    
96
    /**
97
     * Return the thumbnail file path
98
     * @return string
99
     */
100 149
    public function getThumbnailPath()
101
    {
102 149
        return $this->thumbnail;
103
    }
104
    
105
    /**
106
     * Define the path for the thumbnail file / preview picture
107
     * @param string $value
0 ignored issues
show
Bug introduced by
There is no parameter named $value. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
108
     * @return \PhpOffice\PhpPresentation\PresentationProperties
109
     */
110 4
    public function setThumbnailPath($path = '')
111
    {
112 4
        if (file_exists($path)) {
113 4
            $this->thumbnail = $path;
114
        }
115 4
        return $this;
116
    }
117
118
    /**
119
     * Mark a document as final
120
     * @param bool $state
121
     * @return PhpPresentation
122
     */
123 4
    public function markAsFinal($state = true)
124
    {
125 4
        if (is_bool($state)) {
126 4
            $this->markAsFinal = $state;
127
        }
128 4
        return $this;
129
    }
130
131
    /**
132
     * Return if this document is marked as final
133
     * @return bool
134
     */
135 95
    public function isMarkedAsFinal()
136
    {
137 95
        return $this->markAsFinal;
138
    }
139
140
    /**
141
     * Set the zoom of the document (in percentage)
142
     * @param float $zoom
143
     * @return PhpPresentation
144
     */
145 4
    public function setZoom($zoom = 1)
146
    {
147 4
        if (is_numeric($zoom)) {
148 4
            $this->zoom = $zoom;
0 ignored issues
show
Documentation Bug introduced by
It seems like $zoom can also be of type integer or string. However, the property $zoom is declared as type double. Maybe add an additional type check?

Our type inference engine has found a suspicous assignment of a value to a property. This check raises an issue when a value that can be of a mixed type is assigned to a property that is type hinted more strictly.

For example, imagine you have a variable $accountId that can either hold an Id object or false (if there is no account id yet). Your code now assigns that value to the id property of an instance of the Account class. This class holds a proper account, so the id value must no longer be false.

Either this assignment is in error or a type check should be added for that assignment.

class Id
{
    public $id;

    public function __construct($id)
    {
        $this->id = $id;
    }

}

class Account
{
    /** @var  Id $id */
    public $id;
}

$account_id = false;

if (starsAreRight()) {
    $account_id = new Id(42);
}

$account = new Account();
if ($account instanceof Id)
{
    $account->id = $account_id;
}
Loading history...
149
        }
150 4
        return $this;
151
    }
152
153
    /**
154
     * Return the zoom (in percentage)
155
     * @return float
156
     */
157 94
    public function getZoom()
158
    {
159 94
        return $this->zoom;
160
    }
161
162
    /**
163
     * @param string $value
164
     * @return $this
165
     */
166 2
    public function setLastView($value = self::VIEW_SLIDE)
167
    {
168 2
        if (in_array($value, $this->arrayView)) {
169 2
            $this->lastView = $value;
0 ignored issues
show
Documentation Bug introduced by
The property $lastView was declared of type boolean, but $value is of type string. Maybe add a type cast?

This check looks for assignments to scalar types that may be of the wrong type.

To ensure the code behaves as expected, it may be a good idea to add an explicit type cast.

$answer = 42;

$correct = false;

$correct = (bool) $answer;
Loading history...
170
        }
171 2
        return $this;
172
    }
173
174
    /**
175
     * @return string
176
     */
177 93
    public function getLastView()
178
    {
179 93
        return $this->lastView;
180
    }
181
182
    /**
183
     * @param bool $value
184
     * @return $this
185
     */
186 2
    public function setCommentVisible($value = false)
187
    {
188 2
        if (is_bool($value)) {
189 2
            $this->isCommentVisible = $value;
190
        }
191 2
        return $this;
192
    }
193
194
    /**
195
     * @return string
196
     */
197 93
    public function isCommentVisible()
198
    {
199 93
        return $this->isCommentVisible;
200
    }
201
}
202