@@ 535-552 (lines=18) @@ | ||
532 | * |
|
533 | * @since 1.0.0 |
|
534 | */ |
|
535 | public function applyOr(BitArray $bits) |
|
536 | { |
|
537 | if ($this->size == $bits->size) |
|
538 | { |
|
539 | $length = strlen($this->data); |
|
540 | ||
541 | for ($i = 0; $i < $length; $i++) |
|
542 | { |
|
543 | $this->data[$i] = chr(ord($this->data[$i]) | ord($bits->data[$i])); |
|
544 | } |
|
545 | ||
546 | return $this; |
|
547 | } |
|
548 | else |
|
549 | { |
|
550 | throw new \InvalidArgumentException('Argument must be of equal size'); |
|
551 | } |
|
552 | } |
|
553 | ||
554 | /** |
|
555 | * And with an another bit array |
|
@@ 565-582 (lines=18) @@ | ||
562 | * |
|
563 | * @since 1.0.0 |
|
564 | */ |
|
565 | public function applyAnd(BitArray $bits) |
|
566 | { |
|
567 | if ($this->size == $bits->size) |
|
568 | { |
|
569 | $length = strlen($this->data); |
|
570 | ||
571 | for ($i = 0; $i < $length; $i++) |
|
572 | { |
|
573 | $this->data[$i] = chr(ord($this->data[$i]) & ord($bits->data[$i])); |
|
574 | } |
|
575 | ||
576 | return $this; |
|
577 | } |
|
578 | else |
|
579 | { |
|
580 | throw new \InvalidArgumentException('Argument must be of equal size'); |
|
581 | } |
|
582 | } |
|
583 | ||
584 | /** |
|
585 | * Xor with an another bit array |
|
@@ 595-612 (lines=18) @@ | ||
592 | * |
|
593 | * @since 1.0.0 |
|
594 | */ |
|
595 | public function applyXor(BitArray $bits) |
|
596 | { |
|
597 | if ($this->size == $bits->size) |
|
598 | { |
|
599 | $length = strlen($this->data); |
|
600 | ||
601 | for ($i = 0; $i < $length; $i++) |
|
602 | { |
|
603 | $this->data[$i] = chr(ord($this->data[$i]) ^ ord($bits->data[$i])); |
|
604 | } |
|
605 | ||
606 | return $this; |
|
607 | } |
|
608 | else |
|
609 | { |
|
610 | throw new \InvalidArgumentException('Argument must be of equal size'); |
|
611 | } |
|
612 | } |
|
613 | } |
|
614 |