/**
  * @param string $tsvStatement
  * @return FullStatement
  */
 public function parseTsvStatement($tsvStatement)
 {
     $parts = explode("\t", $tsvStatement);
     $partsCount = count($parts);
     if ($partsCount < 3 || $partsCount % 2 != 1) {
         throw new InvalidArgumentException("Invalid statement: {$tsvStatement}");
     }
     list($subject, $property, $object) = $parts;
     $qualifiers = new SnakList();
     $reference = new SnakList();
     for ($i = 3; $i < $partsCount; $i += 2) {
         switch ($parts[$i]) {
             case 'P':
                 $qualifiers->addSnak(new PropertyValueSnak($this->entityIdParser->parse($parts[$i]), $this->parseDataValue($parts[$i + 1])));
                 break;
             case 'S':
                 $reference->addSnak(new PropertyValueSnak($this->entityIdParser->parse(str_replace('S', 'P', $parts[$i])), $this->parseDataValue($parts[$i + 1])));
                 break;
             default:
                 throw new InvalidArgumentException("Invalid statement: {$tsvStatement}");
         }
     }
     return new FullStatement($this->entityIdParser->parse($subject), new Statement(new PropertyValueSnak($this->entityIdParser->parse($property), $this->parseDataValue($object)), $qualifiers, new ReferenceList($reference->isEmpty() ? [new Reference($reference)] : [])));
 }
Esempio n. 2
0
 /**
  * @since 2.6
  *
  * @return bool
  */
 public function isEmpty()
 {
     return $this->snaks->isEmpty();
 }