Skip to content

Commit 45f2d8f

Browse files
committed
_call Setup
1 parent 3e5caf5 commit 45f2d8f

File tree

1 file changed

+19
-0
lines changed

1 file changed

+19
-0
lines changed

app/Wordpress.php

+19
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,25 @@ public function setCredentials(AuthInterface $auth)
5757
$this->credentials = $auth;
5858
}
5959

60+
/**
61+
* @param $endpoint
62+
* @param array $args
63+
* @return Endpoint\AbstractWpEndpoint
64+
*/
65+
public function __call($endpoint, array $args)
66+
{
67+
if (!isset($this->endPoints[$endpoint])) {
68+
$class = 'Reactmore\WordpressClient\Endpoint\\' . ucfirst($endpoint);
69+
if (class_exists($class)) {
70+
$this->endPoints[$endpoint] = new $class($this);
71+
} else {
72+
throw new RuntimeException('Endpoint "' . $endpoint . '" does not exist"');
73+
}
74+
}
75+
76+
return $this->endPoints[$endpoint];
77+
}
78+
6079
/**
6180
* @param RequestInterface $request
6281
* @return ResponseInterface

0 commit comments

Comments
 (0)