LdapTools\Connection\BindUserStrategy::getInstance PHP Méthode

getInstance() public static méthode

Given the LDAP type, determine the BindStrategy to use.
public static getInstance ( DomainConfiguration $config ) : ADBindUserStrategy | BindUserStrategy
$config LdapTools\DomainConfiguration
Résultat LdapTools\Connection\AD\ADBindUserStrategy | BindUserStrategy
    public static function getInstance(DomainConfiguration $config)
    {
        if (LdapConnection::TYPE_AD == $config->getLdapType()) {
            return new ADBindUserStrategy($config);
        } else {
            return new self($config);
        }
    }

Usage Example

 /**
  * @param DomainConfiguration $config
  * @param EventDispatcherInterface $dispatcher
  * @param LdapLoggerInterface $logger
  */
 public function __construct(DomainConfiguration $config, EventDispatcherInterface $dispatcher = null, LdapLoggerInterface $logger = null)
 {
     $this->usernameFormatter = BindUserStrategy::getInstance($config);
     $this->serverPool = new LdapServerPool($config);
     $this->config = $config;
     $this->dispatcher = $dispatcher ?: new SymfonyEventDispatcher();
     $this->logger = $logger;
     $this->setupOperationInvoker();
     $this->serverPool->setSelectionMethod($config->getServerSelection());
     if (!$config->getLazyBind()) {
         $this->connect();
     }
 }