You are here

public function LazyDouble::addInterface in Zircon Profile 8

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

Tells doubler to implement specific interface with double.

Parameters

string|ReflectionClass $interface:

Throws

\Prophecy\Exception\Doubler\InterfaceNotFoundException

\Prophecy\Exception\Doubler\DoubleException

File

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

Class

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

Namespace

Prophecy\Doubler

Code

public function addInterface($interface) {
  if (null !== $this->double) {
    throw new DoubleException('Can not implement interface with already instantiated double.');
  }
  if (!$interface instanceof ReflectionClass) {
    if (!interface_exists($interface)) {
      throw new InterfaceNotFoundException(sprintf('Interface %s not found.', $interface), $interface);
    }
    $interface = new ReflectionClass($interface);
  }
  $this->interfaces[] = $interface;
}