本文整理汇总了PHP中Assert\Assertion::notEmptyKey方法的典型用法代码示例。如果您正苦于以下问题:PHP Assertion::notEmptyKey方法的具体用法?PHP Assertion::notEmptyKey怎么用?PHP Assertion::notEmptyKey使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Assert\Assertion
的用法示例。
在下文中一共展示了Assertion::notEmptyKey方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: join
/**
* {@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: __call
/**
* 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: identify
/**
* {@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]);
}
示例4: __construct
/**
* @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: testInvalidNotEmptyKey
/**
* @dataProvider invalidNotEmptyKeyDataprovider
*/
public function testInvalidNotEmptyKey($invalidArray, $key)
{
$this->setExpectedException('Assert\\InvalidArgumentException');
Assertion::notEmptyKey($invalidArray, $key);
}
示例6: createResult
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: detachSubject
/**
* 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]);
}