Completed
Pull Request — develop (#186)
by
unknown
07:55
created

PresentationProperties::markAsFinal()   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
    /*
25
     * @var boolean
26
     */
27
    protected $isLoopUntilEsc = false;
28
29
    /**
30
     * Mark as final
31
     * @var bool
32
     */
33
    protected $markAsFinal = false;
34
35
    /*
36
     * @var string
37
     */
38
    protected $thumbnail;
39
40
    /**
41
     * Zoom
42
     * @var float
43
     */
44
    protected $zoom = 1;
45
    
46
    /**
47
     * @return bool
48
     */
49 119
    public function isLoopContinuouslyUntilEsc()
50
    {
51 119
        return $this->isLoopUntilEsc;
52
    }
53
    
54
    /**
55
     * @param bool $value
56
     * @return \PhpOffice\PhpPresentation\PresentationProperties
57
     */
58 2
    public function setLoopContinuouslyUntilEsc($value = false)
59
    {
60 2
        if (is_bool($value)) {
61 2
            $this->isLoopUntilEsc = $value;
62
        }
63 2
        return $this;
64
    }
65
    
66
    /**
67
     * Return the thumbnail file path
68
     * @return string
69
     */
70 119
    public function getThumbnailPath()
71
    {
72 119
        return $this->thumbnail;
73
    }
74
    
75
    /**
76
     * Define the path for the thumbnail file / preview picture
77
     * @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...
78
     * @return \PhpOffice\PhpPresentation\PresentationProperties
79
     */
80 4
    public function setThumbnailPath($path = '')
81
    {
82 4
        if (file_exists($path)) {
83 4
            $this->thumbnail = $path;
84
        }
85 4
        return $this;
86
    }
87
88
    /**
89
     * Mark a document as final
90
     * @param bool $state
91
     * @return PhpPresentation
92
     */
93 4
    public function markAsFinal($state = true)
94
    {
95 4
        if (is_bool($state)) {
96 4
            $this->markAsFinal = $state;
97
        }
98 4
        return $this;
99
    }
100
101
    /**
102
     * Return if this document is marked as final
103
     * @return bool
104
     */
105 77
    public function isMarkedAsFinal()
106
    {
107 77
        return $this->markAsFinal;
108
    }
109
110
    /**
111
     * Set the zoom of the document (in percentage)
112
     * @param float $zoom
113
     * @return PhpPresentation
114
     */
115 4
    public function setZoom($zoom = 1)
116
    {
117 4
        if (is_numeric($zoom)) {
118 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...
119
        }
120 4
        return $this;
121
    }
122
123
    /**
124
     * Return the zoom (in percentage)
125
     * @return float
126
     */
127 77
    public function getZoom()
128
    {
129 77
        return $this->zoom;
130
    }
131
}
132