Пример #1
0
 /**
  * @return Mirroring
  */
 private function parseMirroring()
 {
     $isMirrored = $this->getBoolAttribute(self::ATTR_MIRRORED);
     $mirroredByValue = $this->getOptionalAttribute(self::ATTR_MIRROR_GLYPH);
     $mirroredBy = $mirroredByValue !== null ? Codepoint::fromHex($mirroredByValue) : null;
     return new Mirroring($isMirrored, $mirroredBy);
 }
Пример #2
0
 /**
  * @param string $value
  * @param string $encoding
  * @return Codepoint
  * @throws InvalidArgumentException
  */
 private function valueToCodepoint($value, $encoding)
 {
     if ($encoding === self::ENCODING_DECIMAL) {
         return Codepoint::fromInt((int) $value);
     } elseif ($encoding === self::ENCODING_HEXADECIMAL) {
         return Codepoint::fromHex($value);
     } elseif ($encoding === self::ENCODING_UTF8) {
         return Codepoint::fromUTF8($value);
     }
     throw new InvalidArgumentException(sprintf('Unknown encoding: %s', $encoding));
 }
Пример #3
0
 public function it_parses_case_properties()
 {
     $codepoint = Codepoint::fromInt(0);
     $lower = Codepoint::fromHex('65');
     $mappings = new LetterCase\Mappings(new LetterCase\Mapping($lower, [$lower]), new LetterCase\Mapping($codepoint, [$codepoint]), new LetterCase\Mapping($codepoint, [$codepoint]), new LetterCase\Mapping($codepoint, [$codepoint]));
     $expected = new LetterCase($mappings);
     $dom = new \DOMDocument('1.0', 'UTF-8');
     $dom->loadXML(self::XML_DATA);
     $element = $dom->getElementsByTagName('char')->item(0);
     $this->parseElement($element, $codepoint)->shouldBeLike($expected);
 }
Пример #4
0
 /**
  * @param string $list
  * @return Codepoint[]
  */
 protected function parseCodepointList($list)
 {
     $mapper = function ($codepointValue) {
         return Codepoint::fromHex($codepointValue);
     };
     return array_map($mapper, explode(' ', $list));
 }
Пример #5
0
 /**
  * @param string $attribute
  * @return Codepoint
  */
 private function parseSimpleMapping($attribute)
 {
     $codepoint = $this->parsePlaceholders($this->getAttribute($attribute), $this->codepoint);
     return Codepoint::fromHex($codepoint);
 }