Skip to content

Commit 990020a

Browse files
authored
Create BitwiseFlagTrait.php
1 parent b373787 commit 990020a

File tree

1 file changed

+44
-0
lines changed

1 file changed

+44
-0
lines changed

BitwiseFlagTrait.php

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
<?php
2+
3+
namespace App\Traits;
4+
5+
/**
6+
* Class BitwiseFlagTrait
7+
* @package App\Traits
8+
*/
9+
trait BitwiseFlagTrait
10+
{
11+
12+
/**
13+
*
14+
*/
15+
protected static function bootBitwiseFlagTrait()
16+
{
17+
//
18+
}
19+
20+
/**
21+
* @param $name
22+
* @param $flag
23+
* @return bool
24+
*/
25+
protected function isFlagSet($name, $flag)
26+
{
27+
return (($this->$name & $flag) == $flag);
28+
}
29+
30+
/**
31+
* @param string $name
32+
* @param int $flag
33+
* @param $value
34+
* @return bool
35+
*/
36+
protected function setFlag($name, $flag, $value)
37+
{
38+
if ($value) {
39+
$this->$name |= $flag;
40+
} else {
41+
$this->$name &= ~$flag;
42+
}
43+
}
44+
}

0 commit comments

Comments
 (0)