keyIsset() public static method

Assert that key exists in an array/array-accessible object using isset()
public static keyIsset ( mixed $value, string | integer $key, string | null $message = null, string | null $propertyPath = null ) : boolean
$value mixed
$key string | integer
$message string | null
$propertyPath string | null
return boolean
Exemplo n.º 1
0
 /**
  * @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;
 }
Exemplo n.º 3
0
 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');
 }