Total Complexity | 8 |
Total Lines | 31 |
Duplicated Lines | 0 % |
Changes | 1 | ||
Bugs | 0 | Features | 1 |
1 | <?php |
||
21 | abstract class BasePlugin implements PluginInterface |
||
22 | { |
||
23 | |||
24 | public PheanstalkInterface $server; |
||
25 | |||
26 | public function __construct(PheanstalkInterface $server) |
||
27 | { |
||
28 | $this->server = $server; |
||
29 | } |
||
30 | |||
31 | /** |
||
32 | * @return static |
||
33 | */ |
||
34 | public static function createFromGlobals(): PluginInterface |
||
35 | { |
||
36 | $host = getenv('BEANSTALKD_HOST') ?: 'localhost'; |
||
37 | $port = (int)(getenv('BEANSTALKD_PORT') ?: 11300); |
||
38 | $timeout = (int)(getenv('BEANSTALKD_TIMEOUT') ?: 10); |
||
39 | $server = new Pheanstalk( |
||
40 | new Connection(new SocketFactory($host, $port, $timeout)) |
||
41 | ); |
||
42 | return new static($server); |
||
43 | } |
||
44 | |||
45 | public function run(array $argv): string |
||
52 | } |
||
53 | } |
||
54 |