Пример #1
0
 /**
  * @see ValueFormatter::format
  *
  * @param StringValue $dataValue
  *
  * @throws InvalidArgumentException
  * @return string Text
  */
 public function format($dataValue)
 {
     if (!$dataValue instanceof StringValue) {
         throw new InvalidArgumentException('Data value type mismatch. Expected a StringValue.');
     }
     return $dataValue->getValue();
 }
 /**
  * @see ValueFormatter::format
  *
  * Formats the given URL as an HTML link
  *
  * @param StringValue $value The URL to turn into a link
  *
  * @throws InvalidArgumentException
  * @return string HTML
  */
 public function format($value)
 {
     if (!$value instanceof StringValue) {
         throw new InvalidArgumentException('Data value type mismatch. Expected a StringValue.');
     }
     $url = $value->getValue();
     $attributes = array_merge($this->attributes, array('href' => $url));
     $html = Html::element('a', $attributes, $url);
     return $html;
 }
 /**
  * @see ValueFormatter::format
  *
  * Formats the given commons file name as an HTML link
  *
  * @since 0.5
  *
  * @param StringValue $value The commons file name to turn into a link
  *
  * @throws InvalidArgumentException
  * @return string HTML
  */
 public function format($value)
 {
     if (!$value instanceof StringValue) {
         throw new InvalidArgumentException('Data value type mismatch. Expected a StringValue.');
     }
     $fileName = $value->getValue();
     // We are using NS_MAIN only because makeTitleSafe requires a valid namespace
     // We cannot use makeTitle because it does not secureAndSplit()
     $title = Title::makeTitleSafe(NS_MAIN, $fileName);
     if ($title === null) {
         return htmlspecialchars($fileName);
     }
     $attributes = array_merge($this->attributes, array('href' => '//commons.wikimedia.org/wiki/File:' . $title->getPartialURL()));
     $html = Html::element('a', $attributes, $title->getText());
     return $html;
 }
 private function buildStringValueForSearch(PropertyId $propertyId, StringValue $stringValue)
 {
     return $propertyId->getSerialization() . '-' . $this->documentBuilder->buildSearchedStringValue($stringValue->getValue());
 }
 /**
  * @dataProvider instanceProvider
  * @param StringValue $string
  * @param array $arguments
  */
 public function testGetValue(StringValue $string, array $arguments)
 {
     $this->assertEquals($arguments[0], $string->getValue());
 }