LibCloud\Compute\Providers\Rackspace\RackspaceProvider::listSizes PHP Method

listSizes() public method

public listSizes ( $nodeSizeId = null )
    public function listSizes($nodeSizeId = null)
    {
        $sizes = array();
        if ($nodeSizeId) {
            try {
                $sizes[] = $this->getService()->flavor($nodeSizeId);
            } catch (ClientErrorResponseException $e) {
                if (404 !== $e->getResponse()->getStatusCode()) {
                    throw $e;
                }
            }
        } else {
            foreach ($this->getService()->flavorList() as $size) {
                $sizes[] = $size;
            }
        }
        return array_map(array($this, 'toSize'), $sizes);
    }

Usage Example

 public function testListSizesWithId()
 {
     $this->addMockSubscriber($this->getTestFilePath('Flavor'));
     $expectedId = 'compute1-15';
     $sizes = $this->provider->listSizes($expectedId);
     $this->assertCount(1, $sizes, 'listSizes returns an array with exactly one item');
     $this->assertSame($expectedId, $sizes[0]->getId(), 'The NodeSize ID matches the ID that was requested');
 }