/** * @param Type $other * @return bool */ public function sameAs(Type $other) { if (!$other instanceof SingleValue) { return false; } return $this->value() === $other->value(); }
/** * @param Type $type * @param array $metadata * @param FileTypeAdapter $fileTypeAdapter * @param null $itemIndex */ private function writeTypeToFile(Type $type, array &$metadata, FileTypeAdapter $fileTypeAdapter, $itemIndex = null) { $filenameData = [self::FILENAME_DATA_METADATA => $metadata]; if ($type->description()->nativeType() === NativeType::DICTIONARY) { $filenameData[self::FILENAME_DATA_DATA] = $this->dictionaryToArray($type); } elseif ($type instanceof SingleValue) { $filenameData[self::FILENAME_DATA_VALUE] = $type->value(); } if (!is_null($itemIndex)) { $filenameData[self::FILENAME_DATA_ITEM_INDEX] = $itemIndex; } $filename = $this->fileNameRenderer->render($metadata[self::META_FILENAME_TEMPLATE], $filenameData); $fileTypeAdapter->writeDataOfType($metadata[self::META_PATH] . DIRECTORY_SEPARATOR . $filename, $type, $metadata); }
/** * @param Type $other * @return boolean */ public function sameAs(Type $other) { $calledClass = get_called_class(); if (!$other instanceof $calledClass) { return false; } $myProperties = $this->properties(); $otherProperties = $other->properties(); if ($this->description()->hasIdentifier()) { return $myProperties[$this->description()->identifierName()]->type()->sameAs($otherProperties[$this->description()->identifierName()]->type()); } $equalsBuilder = EqualsBuilder::create(); foreach ($this->properties() as $propertyName => $property) { $equalsBuilder->append($property->type()->sameAs($otherProperties[$propertyName]->type())); } return $equalsBuilder->equals(); }
/** * @param Type $type * @return array */ protected function convertToCsvRow(Type $type) { switch ($type->description()->nativeType()) { case NativeType::COLLECTION: case NativeType::DICTIONARY: return array_map(function (Type $item) { return $item->toString(); }, $type->value()); break; default: return [$type->toString()]; } }
/** * @param Type $other * @return bool */ public function sameAs(Type $other) { if (!$other instanceof DateTime) { return false; } return $this->toString() === $other->toString(); }
/** * @param Type $other * @return boolean */ public function sameAs(Type $other) { if (!$other instanceof AbstractCollection) { return false; } return $this->getInnerIterator() === $other->getInnerIterator(); }