Symfony\Component\DependencyInjection\ContainerInterface::has PHP Method

has() public method

Returns true if the given service is defined.
public has ( string $id ) : boolean
$id string The service identifier
return boolean true if the service is defined, false otherwise
    function has($id);

Usage Example

 /**
  * @covers ::knowsDependency
  * @covers ::__construct
  */
 public function testKnowsDependency()
 {
     $this->container->has('known_dependency')->willReturn(true);
     $this->container->has('unknown_dependency')->willReturn(false);
     $this->assertTrue($this->sut->knowsDependency('known_dependency'));
     $this->assertFalse($this->sut->knowsDependency('unknown_dependency'));
 }
All Usage Examples Of Symfony\Component\DependencyInjection\ContainerInterface::has