/** * @param TransformationFormat $format * @return string * @throws InvalidArgumentException */ private static function mapFormat(TransformationFormat $format) { if (!array_key_exists($format->getType(), self::$iconvMap)) { throw new InvalidArgumentException(); } return self::$iconvMap[$format->getType()]; }
public function it_can_be_instantiated_from_encoded_characters() { $start = 'a'; $end = 'z'; $encoding = TransformationFormat::ofType(TransformationFormat::EIGHT); $this->beConstructedThrough('betweenEncodedCharacters', [$start, $end, $encoding]); $this->shouldBeLike(Range::between(Codepoint::fromInt(97), Codepoint::fromInt(122))); }
/** * @return string */ public function toUTF32BE() { return $this->toEncodedString(TransformationFormat::ofType(TransformationFormat::THIRTY_TWO_BIG_ENDIAN)); }
/** * @param TransformationFormat $convertTo * @return string * @throws InvalidArgumentException */ public function toEncodedCharacter(TransformationFormat $convertTo) { $character = pack('N', $this->value); $convertFrom = TransformationFormat::ofType(TransformationFormat::THIRTY_TWO_BIG_ENDIAN); return StringUtility::convertCharacter($character, $convertFrom, $convertTo); }
public function it_should_not_equal_an_instance_with_a_different_value() { $this->beConstructedThrough('ofType', [TransformationFormat::SIXTEEN]); $this->equals(TransformationFormat::ofType(TransformationFormat::EIGHT))->shouldReturn(false); }