PhpSpec\Wrapper\Unwrapper::unwrapOne PHP Method

unwrapOne() public method

public unwrapOne ( mixed $argument ) : mixed
$argument mixed
return mixed
    public function unwrapOne($argument)
    {
        if (is_array($argument)) {
            return array_map(array($this, 'unwrapOne'), $argument);
        }
        if (!is_object($argument)) {
            return $argument;
        }
        if ($argument instanceof ObjectWrapper) {
            return $argument->getWrappedObject();
        }
        if ($argument instanceof ProphecyInterface) {
            $argument = $argument->reveal();
        }
        return $argument;
    }

Usage Example

Esempio n. 1
0
 /**
  * @param string $property
  * @param mixed  $value
  *
  * @return mixed
  *
  * @throws \PhpSpec\Exception\Wrapper\SubjectException
  * @throws \PhpSpec\Exception\Fracture\PropertyNotFoundException
  */
 public function set($property, $value = null)
 {
     if (null === $this->getWrappedObject()) {
         throw $this->settingPropertyOnNonObject($property);
     }
     $unwrapper = new Unwrapper();
     $value = $unwrapper->unwrapOne($value);
     if ($this->isObjectPropertyAccessible($property, true)) {
         return $this->getWrappedObject()->{$property} = $value;
     }
     throw $this->propertyNotFound($property);
 }
All Usage Examples Of PhpSpec\Wrapper\Unwrapper::unwrapOne