1
0
Fork 0

Rename blob rule property to bitfield

pull/4239/head
Nils Adermann 2015-07-09 18:44:56 +02:00
parent 961ea868ac
commit 329ab5cf41
1 changed files with 13 additions and 13 deletions

View File

@ -35,7 +35,7 @@ class Rule
*/ */
public $literals; public $literals;
protected $blob; protected $bitfield;
protected $reasonData; protected $reasonData;
public function __construct(array $literals, $reason, $reasonData, $job = null) public function __construct(array $literals, $reason, $reasonData, $job = null)
@ -50,7 +50,7 @@ class Rule
$this->job = $job; $this->job = $job;
} }
$this->blob = (0 << 16) | ($reason << 8) | (255 << 0); $this->bitfield = (0 << 16) | ($reason << 8) | (255 << 0);
} }
public function getHash() public function getHash()
@ -66,7 +66,7 @@ class Rule
public function getReason() public function getReason()
{ {
return $this->getBlob(1); return $this->getBitfield(1);
} }
public function getReasonData() public function getReasonData()
@ -110,32 +110,32 @@ class Rule
public function setType($type) public function setType($type)
{ {
return $this->setBlob(0, $type); return $this->setBitfield(0, $type);
} }
public function getType() public function getType()
{ {
return $this->getBlob(0); return $this->getBitfield(0);
} }
public function disable() public function disable()
{ {
return $this->setBlob(2, 1); return $this->setBitfield(2, 1);
} }
public function enable() public function enable()
{ {
return $this->setBlob(2, 0); return $this->setBitfield(2, 0);
} }
public function isDisabled() public function isDisabled()
{ {
return (bool) $this->getBlob(2); return (bool) $this->getBitfield(2);
} }
public function isEnabled() public function isEnabled()
{ {
return !$this->getBlob(2); return !$this->getBitfield(2);
} }
/** /**
@ -253,16 +253,16 @@ class Rule
return implode(', ', $prepared); return implode(', ', $prepared);
} }
private function getBlob($var) private function getBitfield($var)
{ {
$offset = 8*$var; $offset = 8*$var;
return ($this->blob & (255 << $offset)) >> $offset; return ($this->bitfield & (255 << $offset)) >> $offset;
} }
private function setBlob($var, $value) private function setBitfield($var, $value)
{ {
$offset = 8*$var; $offset = 8*$var;
$this->blob = ($this->blob & ~(255 << $offset)) | ((255 & $value) << $offset); $this->bitfield = ($this->bitfield & ~(255 << $offset)) | ((255 & $value) << $offset);
} }
/** /**