PassageProxy.php
956 字节
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
<?php
namespace Lackoxygen\TiktokShop\Passage;
use Lackoxygen\TiktokShop\Attribute\Config;
use Lackoxygen\TiktokShop\Exception\ClientException;
class PassageProxy
{
protected string $passage;
protected Config $config;
protected function __construct(string $passage, Config $config)
{
$this->passage = $passage;
$this->config = $config;
}
public static function proxy(string $passage, Config $config): PassageProxy
{
return new self($passage, $config);
}
/**
* @throws ClientException
*/
public function __call($name, $arguments): ResultSet
{
/**
* @var Passage $passage
*/
$passage = new $this->passage($this->config, $name);
$result = call_user_func_array([$passage, $name], $arguments);
if (!is_null($result)) {
return new ResultSet($result);
}
return new ResultSet($passage());
}
}