MaskTrait   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 39
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 1 Features 1
Metric Value
eloc 10
c 1
b 1
f 1
dl 0
loc 39
ccs 8
cts 8
cp 1
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setMask() 0 12 1
A getMask() 0 3 1
1
<?php
2
3
namespace Comodojo\Zip\Traits;
4
5
use \Comodojo\Zip\Interfaces\ZipInterface;
6
7
/**
8
 * File mask helper trait.
9
 *
10
 * @package     Comodojo Zip
11
 * @author      Marco Giovinazzi <[email protected]>
12
 * @license     MIT
13
 *
14
 * LICENSE:
15
 *
16
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
19
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
21
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
22
 * THE SOFTWARE.
23
 */
24
25
trait MaskTrait
26
{
27
28
    /**
29
     * Mask for the extraction folder (if it should be created)
30
     *
31
     * @var int
32
     */
33
    private int $mask = 0777;
34
35
    /**
36
     * Set the mask of the extraction folder
37
     *
38
     * @param int $mask Integer representation of the file mask
39
     *
40
     * @return ZipInterface
41
     */
42 1
    public function setMask(int $mask): ZipInterface
43
    {
44 1
        $mask = filter_var($mask, FILTER_VALIDATE_INT, [
45
            "options" => [
46 1
                "max_range" => 0777,
47
                "default" => 0777
48
            ],
49 1
            'flags' => FILTER_FLAG_ALLOW_OCTAL
50
        ]);
51 1
        $this->mask = $mask;
52
53 1
        return $this;
54
    }
55
56
    /**
57
     * Get current mask of the extraction folder
58
     *
59
     * @return int
60
     */
61 5
    public function getMask(): int
62
    {
63 5
        return $this->mask;
64
    }
65
}
66