Completed
Pull Request — master (#553)
by
unknown
02:35
created

AbstractComponent::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 6

Importance

Changes 0
Metric Value
cc 2
eloc 4
nc 2
nop 3
dl 0
loc 6
rs 9.4285
c 0
b 0
f 0
ccs 0
cts 6
cp 0
crap 6
1
<?php
2
3
/*
4
 * This file is part of the overtrue/wechat.
5
 *
6
 * (c) overtrue <[email protected]>
7
 *
8
 * This source file is subject to the MIT license that is bundled
9
 * with this source code in the file LICENSE.
10
 */
11
12
/**
13
 * AbstractComponent.php.
14
 *
15
 * Part of Overtrue\WeChat.
16
 *
17
 * For the full copyright and license information, please view the LICENSE
18
 * file that was distributed with this source code.
19
 *
20
 * @author    mingyoung <[email protected]>
21
 * @copyright 2016
22
 *
23
 * @see      https://github.com/overtrue
24
 * @see      http://overtrue.me
25
 */
26
27
namespace EasyWeChat\OpenPlatform\Components;
28
29
use EasyWeChat\Core\AbstractAPI;
30
use Symfony\Component\HttpFoundation\Request;
31
32
abstract class AbstractComponent extends AbstractAPI
33
{
34
    /**
35
     * Config.
36
     *
37
     * @var array
38
     */
39
    protected $config;
40
41
    /**
42
     * Request.
43
     *
44
     * @var Symfony\Component\HttpFoundation\Request
45
     */
46
    protected $request;
47
48
    /**
49
     * AbstractComponent constructor.
50
     *
51
     * @param \EasyWeChat\Core\AccessToken $accessToken
52
     * @param array                        $config
53
     * @param $request
54
     */
55
    public function __construct($accessToken, array $config, $request = null)
56
    {
57
        parent::__construct($accessToken);
58
        $this->config = $config;
59
        $this->request = $request ?: Request::createFromGlobals();
60
    }
61
}
62