notEmptyKey() public static method

Assert that key exists in an array/array-accessible object and it's value is not empty.
public static notEmptyKey ( 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
 /**
  * {@inheritdoc}
  */
 public function join(string $channel, array $data = [])
 {
     Assertion::notEmptyKey($data, 'socketId', "Invalid socket id");
     Assertion::notEmptyKey($data, 'userId', "Invalid user id");
     Assertion::notEmptyKey($data, 'fullName', "Invalid full name");
     return $this->pusher->presence_auth($channel, $data['socketId'], $data['userId'], ['id' => $data['userId'], 'name' => utf8_encode($data['fullName'])]);
 }
示例#2
0
 /**
  * Returns dynamic properties passed to the object
  *
  * Notice: property names should be camelCased
  *
  * @param string $method
  * @param array  $arguments
  *
  * @return mixed
  *
  * @throws BadMethodCallException If $method is not a property
  */
 public function __call($method, array $arguments)
 {
     if (substr($method, 0, 3) === 'get' and $property = substr($method, 3)) {
         $property = lcfirst($property);
         Assertion::notEmptyKey($this->data, $property, 'User does not have a(n) "%s" property');
         return $this->data[$property];
     }
     throw new \BadMethodCallException(sprintf('Method "%s" does not exists', $method));
 }
示例#3
0
 /**
  * {@inheritdoc}
  */
 public function identify(array $subject)
 {
     Assertion::notEmptyKey($subject, 'username');
     if (!in_array($subject['username'], $this->userKeys)) {
         throw new IdentificationFailed('User not found');
     }
     $id = array_search($subject['username'], $this->userKeys);
     return new SimpleUser($id, $this->users[$id]);
 }
 /**
  * @param array $configuration Array with configuration settings
  * @throws InvalidArgumentException
  */
 public function __construct(array $configuration)
 {
     // Validate and set base url
     Assertion::notEmptyKey($configuration, 'apiBaseUrl', 'apiBaseUrl is required');
     Assertion::url($configuration['apiBaseUrl'], 'apiBaseUrl has to be a valid url');
     $this->apiBaseUrl = rtrim($configuration['apiBaseUrl'], '/');
     // Validate username
     Assertion::notEmptyKey($configuration, 'username', 'username is required');
     Assertion::string($configuration['username'], 'username has to be a string');
     $this->username = trim($configuration['username']);
     // Validate api interface id
     Assertion::notEmptyKey($configuration, 'apiId', 'apiId is required');
     Assertion::integer($configuration['apiId'], 'apiId has to be an integer');
     $this->apiId = trim($configuration['apiId']);
     // Validate api key
     Assertion::notEmptyKey($configuration, 'apiKey', 'apiKey is required');
     Assertion::string($configuration['apiKey'], 'apiKey has to be a string');
     $this->apiKey = trim($configuration['apiKey']);
     // Check if clientConfiguration is set and valid
     if (isset($configuration['clientConfiguration'])) {
         Assertion::isArray($configuration['clientConfiguration'], 'clientConfiguration has to be an array');
         $this->clientConfiguration = $configuration['clientConfiguration'];
     }
 }
示例#5
0
 /**
  * @dataProvider invalidNotEmptyKeyDataprovider
  */
 public function testInvalidNotEmptyKey($invalidArray, $key)
 {
     $this->setExpectedException('Assert\\InvalidArgumentException');
     Assertion::notEmptyKey($invalidArray, $key);
 }
示例#6
0
 private function createResult(array $result_data)
 {
     Assertion::notEmptyKey($result_data, self::OBJECT_TYPE);
     return $this->projection_type_map->getItem($result_data[self::OBJECT_TYPE])->createEntity($result_data);
 }
示例#7
0
 /**
  * Unregisters a subject from a specific event.
  *
  * @param string $event
  * @param string $key
  */
 public function detachSubject($event, $key)
 {
     Assertion::notEmptyKey($this->subjects, $event, 'Provided event does not exist.');
     Assertion::notEmptyKey($this->subjects[$event], $key, 'Subject to be detached does not exist.');
     unset($this->subjects[$event][$key]);
 }