示例#1
0
 /**
  * Converts instance of \ArrayAccess to key => value array entry
  *
  * @param \ArrayAccess $object
  *
  * @return array|null
  * @throws \Prophecy\Exception\InvalidArgumentException
  */
 private function convertArrayAccessToEntry(\ArrayAccess $object)
 {
     if (!$this->key instanceof ExactValueToken) {
         throw new InvalidArgumentException(sprintf('You can only use exact value tokens to match key of ArrayAccess object' . PHP_EOL . 'But you used `%s`.', $this->key));
     }
     $key = $this->key->getValue();
     return $object->offsetExists($key) ? array($key => $object[$key]) : array();
 }