DirkGroenen\Pinterest\Pinterest::__get PHP Метод

__get() публичный Метод

Get an Pinterest API endpoint
public __get ( string $endpoint ) : mixed
$endpoint string
Результат mixed
    public function __get($endpoint)
    {
        $endpoint = strtolower($endpoint);
        $class = "\\DirkGroenen\\Pinterest\\Endpoints\\" . ucfirst($endpoint);
        // Check if an instance has already been initiated
        if (!isset($this->cachedEndpoints[$endpoint])) {
            // Check endpoint existence
            if (!class_exists($class)) {
                throw new InvalidEndpointException();
            }
            // Create a reflection of the called class and initialize it
            // with a reference to the request class
            $ref = new \ReflectionClass($class);
            $obj = $ref->newInstanceArgs([$this->request, $this]);
            $this->cachedEndpoints[$endpoint] = $obj;
        }
        return $this->cachedEndpoints[$endpoint];
    }