/** * @param string $location * * @return static */ public static function fromString($location) { Assertion::string($location); $result = explode('.', $location); Assertion::keyIsset($result, 0); Assertion::keyIsset($result, 1); return new static((int) $result[0], (int) $result[1]); }
/** * @param string $entityClass * * @return DataMapperInterface */ public function getDataMapperForEntity($entityClass) { Assertion::keyIsset($this->entityDataMapperMap, $entityClass, sprintf("Could not find data mapper service name for entity class '%s'", $entityClass)); $entityDMServiceName = $this->entityDataMapperMap[$entityClass]; $dataMapper = $this->get($entityDMServiceName); if (!is_a($dataMapper->getEntityClass(), $entityClass, true)) { throw new Exception\RuntimeException(sprintf('"%s" entity class mismatch: expected "%s", got "%s"', $entityDMServiceName, $entityClass, $dataMapper->getEntityClass())); } return $dataMapper; }
public function getTemplateService($eng = "") { $ret = null; // spécify engine or use default $engine = $eng == "" ? TEMPLATE_ENGINE : $eng; try { Assertion::keyIsset($this->arr, $engine, "Template engine {$engine} is not defined"); $class = $this->arr[$engine]; Assertion::ClassExists($class); $ret = new $class(); } catch (Exception $e) { } return $ret; }
public function __construct(CommitteeId $id, string $name, string $summary, Email $email = null, string $markDown = '', string $html = '', array $members = []) { $this->id = (string) $id; $this->name = $name; $this->summary = $summary; $this->email = (string) $email; $this->markDown = $markDown; $this->html = $html; foreach ($members as $member) { Assertion::keyIsset($member, 'id'); Assertion::keyIsset($member, 'first_name'); Assertion::keyIsset($member, 'last_name'); } $this->members = $members; }
/** * @Then I should see :arg1 for property :arg2 */ public function iShouldSee($arg1, $arg2) { Assertion::keyIsset($this->response['errors'], $arg2); Assertion::inArray($arg1, $this->response['errors'][$arg2]); }
/** * @Then /^I should see suggestions for my username$/ */ public function checkNameSuggestions() { Assertion::keyIsset($this->apiContext->getResponse(), 'name_suggestions'); }