/** * {@inheritdoc} */ public function getMessages(ConversationInterface $conversation, $offset = 0, $limit = 20, $sortDirection = 'ASC') { Assert::integer($offset, '$offset expected an integer in Repository::getMessages(). Got: %s'); Assert::integer($limit, '$limit expected an integer in Repository::getMessages(). Got: %s'); Assert::oneOf(strtoupper($sortDirection), ['ASC', 'DESC'], '$sortDirection expected either ASC or DESC in Repository::getMessages(). Got: %s'); return $this->driver->findMessages($conversation, $offset, $limit, $sortDirection); }
/** * Creates the violation. * * @param int $code The violation code. One of the constants * defined in this class. * @param mixed $invalidValue The value that caused this violation. * @param string $installerName The name of the validated installer. * @param string|null $parameterName The name of the validated installer * parameter or `null` if this is a generic * error. */ public function __construct($code, $invalidValue, $installerName, $parameterName = null) { Assert::oneOf($code, self::$codes, 'The violation code %s is not valid.'); Assert::stringNotEmpty($installerName, 'The installer name must be a non-empty string. Got: %s'); Assert::nullOrStringNotEmpty($parameterName, 'The parameter name must be a non-empty string or null. Got: %s'); $this->code = $code; $this->installerName = $installerName; $this->parameterName = $parameterName; $this->invalidValue = $invalidValue; }
/** * Creates a new package DTO. * * @param string $name The package name. * @param string $installerName The name of the installer. * @param string $installPath The absolute install path. * @param string $state One of the STATE_* constants in this class. */ public function __construct($name, $installerName, $installPath, $state) { Assert::stringNotEmpty($name, 'The package name must be a non-empty string. Got: %s'); Assert::string($installerName, 'The installer name must be a string. Got: %s'); Assert::stringNotEmpty($installPath, 'The install path must be a non-empty string. Got: %s'); Assert::oneOf($state, self::$states, 'The package state must be one of %2$s. Got: %s'); $this->name = $name; $this->installerName = $installerName; $this->installPath = $installPath; $this->state = $state; }
/** * @param TaxonInterface $taxon * @param string $direction * * @throws ElementNotFoundException */ private function moveLeaf(TaxonInterface $taxon, $direction) { Assert::oneOf($direction, [self::MOVE_DIRECTION_UP, self::MOVE_DIRECTION_DOWN]); $leaves = $this->getLeaves(); foreach ($leaves as $leaf) { if ($leaf->getText() === $taxon->getName()) { $moveButton = $leaf->getParent()->find('css', sprintf('.sylius-taxon-move-%s', $direction)); $moveButton->click(); $moveButton->waitFor(5, function () use($moveButton) { return $this->isOpen() && !$moveButton->hasClass('loading'); }); return; } } throw new ElementNotFoundException($this->getDriver(), sprintf('Move %s button for %s taxon', $direction, $taxon->getName())); }
/** * @param string $type */ private function assertAddressType($type) { $availableTypes = [self::TYPE_BILLING, self::TYPE_SHIPPING]; Assert::oneOf($type, $availableTypes, sprintf('There are only two available types %s, %s. %s given', self::TYPE_BILLING, self::TYPE_SHIPPING, $type)); }
/** * Sets the verbosity level of the output. * * @param int $verbosity One of the constants {@link NORMAL}, {@link VERBOSE}, * {@link VERY_VERBOSE} or {@link DEBUG}. Only output * with the given verbosity level or smaller will be * written out. */ public function setVerbosity($verbosity) { Assert::oneOf($verbosity, array(IO::NORMAL, IO::VERBOSE, IO::VERY_VERBOSE, IO::DEBUG), 'The verbosity must be one of IO::NORMAL, IO::VERBOSE, IO::VERY_VERBOSE and IO::DEBUG.'); $this->verbosity = (int) $verbosity; }
/** * @Then I should be able to shop using the :currencyCode currency */ public function iShouldBeAbleToShopUsingTheCurrency($currencyCode) { $this->homePage->open(); Assert::oneOf($currencyCode, $this->homePage->getAvailableCurrencies()); }
/** * @Then I should be able to shop using the :localeName locale */ public function iShouldBeAbleToShopUsingTheLocale($localeName) { $this->homePage->open(); Assert::oneOf($localeName, $this->homePage->getAvailableLocales()); }
/** * Returns the default column alignment. * * @param int $alignment One of the {@link Alignment} constants. * * @return static The current instance. */ public function setDefaultColumnAlignment($alignment) { Assert::oneOf($alignment, Alignment::all(), 'The default column alignment must be one of the Alignment constants. Got: %s'); $this->defaultColumnAlignment = $alignment; return $this; }
/** * @param string $name * * @return mixed */ public function getDetail($name) { Assert::oneOf($name, array_keys($this->details), 'ParsedKey::getDetail() expected one of: %2$s. Got: %s'); return $this->details[$name]; }
/** * Find a resource URL. * * @param string $resource * * @return string */ public function getResourceUrl($resource) { Assert::oneOf($resource, self::getResourcesNames(), 'Resource type "%s" is not supported by the ACME server (supported: %2$s)'); return isset($this->serverResources[$resource]) ? $this->serverResources[$resource] : null; }
/** * Set searchedRelationType * * @param string $searchedRelationType * @return User */ public function setSearchedRelationType($searchedRelationType) { Assert::oneOf($searchedRelationType, self::availableSearchingTypes()); $this->searchedRelationType = $searchedRelationType; return $this; }
/** * Set type * * @param string $type * @return Course */ public function setType($type) { Assert::oneOf($type, [self::TYPE_C, self::TYPE_TD, self::TYPE_TP]); $this->type = $type; $this->refreshKey(); return $this; }
/** * Sets the cell alignment. * * @param int $alignment One of the {@link Alignment} constants. * * @return static The current instance. */ public function setCellAlignment($alignment) { Assert::oneOf($alignment, Alignment::all(), 'The cell alignment must be one of the Alignment constants. Got: %s'); $this->cellAlignment = $alignment; return $this; }