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

BitMask   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
c 1
b 0
f 1
lcom 0
cbo 0
dl 0
loc 31
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A set() 0 9 2
A toInt() 0 4 1
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