Nelmio\Alice\Generator\Instantiator\Chainable\StaticFactoryInstantiator::canInstantiate PHP Method

canInstantiate() public method

public canInstantiate ( Nelmio\Alice\FixtureInterface $fixture ) : boolean
$fixture Nelmio\Alice\FixtureInterface
return boolean
    public function canInstantiate(FixtureInterface $fixture) : bool
    {
        $constructor = $fixture->getSpecs()->getConstructor();
        return null !== $constructor && false === $constructor instanceof NoMethodCall && $constructor->getCaller() instanceof StaticReference;
    }

Usage Example

 public function testCanInstantiateFixtureWithIfConstructorIsAStaticFactory()
 {
     $fixture = new SimpleFixture('dummy', 'Dummy', SpecificationBagFactory::create(new MethodCallWithReference(new StaticReference('static_reference'), 'fake')));
     $this->assertTrue($this->instantiator->canInstantiate($fixture));
 }
StaticFactoryInstantiator