Scalr\Service\Aws::getAccountNumber PHP Method

getAccountNumber() public method

Retrieves AWS Account Number
public getAccountNumber ( ) : string
return string Returns AWS Account number for current user
    public function getAccountNumber()
    {
        if ($this->awsAccountNumber === null) {
            try {
                $arr = preg_split('/\\:/', $this->iam->user->fetch()->arn);
                $this->awsAccountNumber = $arr[4];
            } catch (ClientException $e) {
                if (preg_match('/arn\\:aws[\\w-]*\\:iam\\:\\:(\\d+)\\:user/', $e->getMessage(), $matches)) {
                    $this->awsAccountNumber = $matches[1];
                } else {
                    throw $e;
                }
            }
        }
        return $this->awsAccountNumber;
    }