Completed
Push — master ( 59b3e2...6dd6b9 )
by Andrii
15:38
created

Request::createWorker()

Size

Total Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 1
c 0
b 0
f 0
nc 1
1
<?php
2
/**
3
 * Tools to use API as ActiveRecord for Yii2
4
 *
5
 * @link      https://github.com/hiqdev/yii2-hiart
6
 * @package   yii2-hiart
7
 * @license   BSD-3-Clause
8
 * @copyright Copyright (c) 2015-2017, HiQDev (http://hiqdev.com/)
9
 */
10
11
namespace hiqdev\hiart\proxy;
12
13
abstract class Request extends \hiqdev\hiart\AbstractRequest
14
{
15
    /**
16
     * @var object
17
     */
18
    protected $worker;
19
20
    /**
21
     * @var string transport implementation to be specified in concrete implementation.
22
     */
23
    public $handlerClass;
24
25
    abstract protected function createWorker();
26
27
    public function send($options = [])
28
    {
29
        $worker = $this->getHandler()->send($this->getWorker(), $options);
30
31
        return new $this->responseClass($this, $worker);
32
    }
33
34
    /**
35
     * @return Worker
36
     */
37
    public function getWorker()
38
    {
39
        if ($this->worker === null) {
40
            $this->build();
41
            $this->worker = $this->createWorker();
42
        }
43
44
        return $this->worker;
45
    }
46
}
47