Example #1
0
 /**
  * {@inheritdoc}
  */
 public function toPhonetic(HexFormatContext $context)
 {
     $context->setCurrentNibble($this);
     if ($this->isNumeric()) {
         return NumericHexFormatter::getInstance()->format($this);
     }
     return NibbleEnum::find($this, $context->isFirstNibble());
 }
 /**
  * Return empty string for null nibbles
  *
  * @param HexFormatContext $context
  * @return string
  */
 public function toPhonetic(HexFormatContext $context)
 {
     $context->setCurrentNibble($this);
     return '';
 }
 /**
  * Test if current byte context open ended
  *
  * @param HexFormatContext $context
  * @return bool
  */
 private function isOpenEndedByte(HexFormatContext $context)
 {
     return $context->getCurrentByte()->getSecondNibble() instanceof NullNibble || $context->getCurrentByte()->getSecondNibble()->isZero();
 }
Example #4
0
 /**
  * {@inheritdoc}
  */
 public function toPhonetic(HexFormatContext $context)
 {
     $context->setCurrentByte($this);
     if ($this->isNumeric()) {
         return NumericHexFormatter::getInstance()->format($this);
     }
     if ($this->isTeen()) {
         return ByteEnum::search((string) $this);
     }
     $first = $this->firstNibble->toPhonetic($context);
     $second = $this->secondNibble->toPhonetic($context);
     $join = NibbleJoiner::getInstance()->join($first, $second);
     return sprintf('%s%s%s', $first, $join, $second);
 }