Scalr\Service\Aws::__get PHP 메소드

__get() 공개 메소드

Magic getter
public __get ( string $name ) : mixed | null
$name string
리턴 mixed | null
    public function __get($name)
    {
        //Retrieves service provider object
        if (in_array($n = lcfirst($name), $this->getAvailableServiceInterfaces())) {
            if (!isset($this->serviceInterfaces[$n])) {
                //It validates region only for the services which it is necessary for.
                if (!in_array($n, array(self::SERVICE_INTERFACE_IAM, self::SERVICE_INTERFACE_S3, self::SERVICE_INTERFACE_CLOUD_FRONT))) {
                    if (!$this->isValidRegion($this->region)) {
                        throw new AwsException(sprintf('Invalid region "%s" for the service "%s"', $this->region, $n));
                    }
                }
                $class = __CLASS__ . '\\' . ucfirst($n);
                try {
                    /* @var $service ServiceInterface */
                    $service = new $class($this);
                    $this->serviceInterfaces[$n] = $service;
                } catch (\Exception $e) {
                    throw new AwsException('Cannot create service interface instance of ' . $class . ' ' . $e->getMessage());
                }
            } else {
                $service = $this->serviceInterfaces[$n];
            }
            return $service;
        }
        return null;
    }