/**
  * @param int $amount
  * @return \Emris\Cli\Scaler\Domain\ServerCollection
  */
 public function remove($amount = 0)
 {
     $serversRemoved = new ServerCollection();
     $serversToRemove = $this->adapter->servers();
     $index = $serversToRemove->count();
     while ($index) {
         if ($this->adapter->delServer($serversToRemove[--$index])) {
             $serversRemoved->add($serversToRemove[$index]);
             if ($index <= $amount) {
                 break;
             }
         }
     }
     return $serversRemoved;
 }
            $actual = $this->srvrMgr->servers();
            expect($actual)->to->be->instanceof('Emris\\Cli\\Scaler\\Domain\\ServerCollection');
            expect($actual->count())->to->equal(3);
        });
    });
    describe('->add($servers)', function () {
        beforeEach(function () {
            $this->srvrBldr = new ServerBuilder();
            $this->adapterMock->addServer($this->srvrBldr->build())->willReturn(true);
        });
        it('should return true', function () {
            $actual = $this->srvrMgr->add(new ServerCollection());
            expect($actual)->to->be->false();
        });
    });
    describe('->remove($servers)', function () {
        beforeEach(function () {
            $servers = new ServerCollection();
            $servers->add($this->srvrBldr->build());
            $servers->add($this->srvrBldr->build());
            $this->srvrBldr = new ServerBuilder();
            $this->adapterMock->servers()->willReturn(new ServerCollection());
            $this->adapterMock->delServer($this->srvrBldr->build())->willReturn(true);
        });
        it('should return ServerCollection of count 2', function () {
            /** @var \Emris\Cli\Scaler\Domain\ServerCollection $actual */
            $actual = $this->srvrMgr->remove(2);
            expect($actual->count())->to->equal(0);
        });
    });
});
 /**
  * @return \Emris\Cli\Scaler\Domain\ServerCollection|null
  * @throws \RuntimeException
  */
 public function servers()
 {
     $url = $this->base . '/upstream_conf?upstream=' . $this->upstream;
     $contents = $this->_call($url);
     /** @noinspection IsEmptyFunctionUsageInspection */
     if (empty($contents)) {
         return null;
     }
     $servers = new ServerCollection();
     $lines = explode(PHP_EOL, $contents);
     foreach ($lines as $line) {
         $server = $this->parseServer($line);
         if ($server[0] === null) {
             break;
         }
         $this->builder->setId($server[0]);
         $this->builder->setIp($server[1]);
         $this->builder->setPort($server[2]);
         /** @noinspection DisconnectedForeachInstructionInspection */
         $servers->add($this->builder->build());
     }
     return $servers;
 }