/** * Returns true if the specified version is valid (can be added) to the collection. Otherwise, it MUST throw * an exception. * * @param DeltaInterface $version * * @return bool * * @throws CollectionException */ public function validate(DeltaInterface $version) { if (!$version->isMigrated()) { throw new CollectionException('Invalid version specified: this collection only accepts deltas that are migrated.'); } return parent::validate($version); }
/** * @inheritdoc */ public final function update(DeltaInterface $version) { if ($version->isMigrated()) { $result = $this->save($version); } else { $result = $this->delete($version); } return $result; }
/** * Returns true if the operation is forced, or if the direction is the opposite to the state of the migration. * * @param DeltaInterface $version * @param OptionsInterface $options * * @return bool */ protected function shouldMigrate(DeltaInterface $version, OptionsInterface $options) { return $options->isForced() || $options->getDirection()->isUp() ^ $version->isMigrated(); // direction is opposite to state }