original_string: public function getActiveEndpoint()
      {
          // try to get endpoint with status active
          $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
              return $endpoint->isActive();
          });
  
          // when empty, try other endpoints
          if ($active->isEmpty() === true) {
              $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
                  return $this->canBeActivated($endpoint);
              });
          }
  
          if ($active->isEmpty() === true) {
              throw new NoServerAvailableException('No active server available');
          }
  
          /** @var Endpoint $endpoint */
          $endpoint = $active->first();
          $endpoint->setStatus(Endpoint::STATUS_ACTIVE);
  
          return $endpoint;
      }
code: public function getActiveEndpoint()
      {
          // try to get endpoint with status active
          $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
              return $endpoint->isActive();
          });
  
          // when empty, try other endpoints
          if ($active->isEmpty() === true) {
              $active = $this->getEndpoints()->filter(function (Endpoint $endpoint) {
                  return $this->canBeActivated($endpoint);
              });
          }
  
          if ($active->isEmpty() === true) {
              throw new NoServerAvailableException('No active server available');
          }
  
          /** @var Endpoint $endpoint */
          $endpoint = $active->first();
          $endpoint->setStatus(Endpoint::STATUS_ACTIVE);
  
          return $endpoint;
      }
code_tokens: public function getActiveEndpoint ( ) { // try to get endpoint with status active $ active = $ this -> getEndpoints ( ) -> filter ( function ( Endpoint $ endpoint ) { return $ endpoint -> isActive ( ) ; } ) ; // when empty, try other endpoints if ( $ active -> isEmpty ( ) === true ) { $ active = $ this -> getEndpoints ( ) -> filter ( function ( Endpoint $ endpoint ) { return $ this -> canBeActivated ( $ endpoint ) ; } ) ; } if ( $ active -> isEmpty ( ) === true ) { throw new NoServerAvailableException ( 'No active server available' ) ; } /** @var Endpoint $endpoint */ $ endpoint = $ active -> first ( ) ; $ endpoint -> setStatus ( Endpoint :: STATUS_ACTIVE ) ; return $ endpoint ; }
docstring: Returns a active endpoint.
  Tries to find the current active endpoint, or enable one.
  
  @return Endpoint
  
  @throws NoServerAvailableException
docstring_tokens: Returns a active endpoint . Tries to find the current active endpoint or enable one .