Completed
Push — master ( 27391f...7a405c )
by Ben
02:18
created

BitMask::toInt()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
c 1
b 0
f 1
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 0
1
<?php
2
/**
3
 * BaconPdf
4
 *
5
 * @link      http://github.com/Bacon/BaconPdf For the canonical source repository
6
 * @copyright 2015 Ben Scholzen (DASPRiD)
7
 * @license   http://opensource.org/licenses/BSD-2-Clause Simplified BSD License
8
 */
9
10
namespace Bacon\Pdf\Encryption;
11
12
/**
13
 * Bit mask for representing permissions.
14
 */
15
final class BitMask
16
{
17
    /**
18
     * @var int
19
     */
20
    private $value = 0;
21
22
    /**
23
     * Sets
24
     *
25
     * @param int  $bit
26
     * @param bool $value
27
     */
28
    public function set($bit, $value)
29
    {
30
        if ($value) {
31
            $this->value |= (1 << $bit);
32
            return;
33
        }
34
35
        $this->value &= ~(1 << $bit);
36
    }
37
38
    /**
39
     * @return int
40
     */
41
    public function toInt()
42
    {
43
        return $this->value;
44
    }
45
}
46