Options   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 3
eloc 8
c 1
b 0
f 1
dl 0
loc 27
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A options() 0 6 2
A configure() 0 4 1
1
<?php
2
/**
3
 * Options for client dispatcher
4
 * User: moyo
5
 * Date: 2018/5/25
6
 * Time: 11:30 AM
7
 */
8
9
namespace Carno\HRPC\Client\Chips;
10
11
use Carno\HTTP\Options as HOptions;
12
use Carno\Pool\Options as POptions;
13
use Closure;
14
15
trait Options
16
{
17
    /**
18
     * @var Closure
19
     */
20
    private $generator = null;
21
22
    /**
23
     * @param Closure $generator
24
     * @return static
25
     */
26
    public function configure(Closure $generator) : self
27
    {
28
        $this->generator = $generator;
29
        return $this;
30
    }
31
32
    /**
33
     * @param string $server
34
     * @return HOptions
35
     */
36
    private function options(string $server) : HOptions
37
    {
38
        if ($this->generator) {
39
            return ($this->generator)($server);
40
        } else {
41
            return (new HOptions())->setTimeouts()->keepalive(new POptions(), "rpc:{$server}");
42
        }
43
    }
44
}
45