/** * @param string|integer $id * @param array $data */ public function __construct($id, $data) { // TODO: check for id's type Assertion::choicesNotEmpty($data, ['username', 'password']); $this->id = $id; $this->data = $data; }
/** * {@inheritdoc} */ public function authenticate($subject, Caller $caller) { Assertion::isArray($subject); Assertion::choicesNotEmpty($subject, ['password']); Assertion::isInstanceOf($caller, 'Guardian\\User\\Caller', sprintf('The caller was expected to be an instance of "%s"', 'Indigo\\Guardian\\Caller\\User')); return $this->hasher->verify($subject['password'], $caller->getPassword()); }
/** * {@inheritDoc} */ public function denormalize($data, $class, $format = null, array $context = []) { Assertion::choicesNotEmpty($data, ['message', 'class', 'timestamp']); Assertion::classExists($data['class']); $envelope = new Envelope($this->aggregate->denormalize($data['message'], $data['class'])); $this->forcePropertyValue($envelope, 'class', $data['class']); $this->forcePropertyValue($envelope, 'timestamp', $data['timestamp']); return $envelope; }
/** * @dataProvider invalidChoicesProvider */ public function testChoicesNotEmptyExpectingException($values, $choices, $exceptionCode) { $this->setExpectedException('Assert\\AssertionFailedException', null, $exceptionCode); Assertion::choicesNotEmpty($values, $choices); }
/** * {@inheritdoc} */ public function denormalize($data, $class, $format = null, array $context = []) { Assertion::choicesNotEmpty($data, ['name', 'arguments']); return new DefaultMessage($data['name'], $data['arguments']); }