You are here

public function LazyDouble::setParentClass in Zircon Profile 8.0

Same name and namespace in other branches
  1. 8 vendor/phpspec/prophecy/src/Prophecy/Doubler/LazyDouble.php \Prophecy\Doubler\LazyDouble::setParentClass()

Tells doubler to use specific class as parent one for double.

Parameters

string|ReflectionClass $class:

Throws

\Prophecy\Exception\Doubler\ClassNotFoundException

\Prophecy\Exception\Doubler\DoubleException

File

vendor/phpspec/prophecy/src/Prophecy/Doubler/LazyDouble.php, line 51

Class

LazyDouble
Lazy double. Gives simple interface to describe double before creating it.

Namespace

Prophecy\Doubler

Code

public function setParentClass($class) {
  if (null !== $this->double) {
    throw new DoubleException('Can not extend class with already instantiated double.');
  }
  if (!$class instanceof ReflectionClass) {
    if (!class_exists($class)) {
      throw new ClassNotFoundException(sprintf('Class %s not found.', $class), $class);
    }
    $class = new ReflectionClass($class);
  }
  $this->class = $class;
}