NewsletterModule::setService()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 3
rs 10
c 0
b 0
f 0
cc 1
eloc 1
nc 1
nop 1
1
<?php
2
/**
3
 * @link https://github.com/yiimaker/yii2-newsletter
4
 * @copyright Copyright (c) 2017 Yii Maker
5
 * @license BSD 3-Clause License
6
 */
7
8
namespace ymaker\newsletter\common\base;
9
10
use Yii;
11
use ymaker\newsletter\common\services\DbService;
12
use ymaker\newsletter\common\services\ServiceInterface;
13
14
/**
15
 * Base newsletter module.
16
 *
17
 * @author Vladimir Kuprienko <[email protected]>
18
 * @since 1.0
19
 */
20
class NewsletterModule extends \yii\base\Module
21
{
22
    /**
23
     * Configuration of service.
24
     *
25
     * @var array
26
     */
27
    private $_service = null;
28
29
30
    /**
31
     * Setter for service
32
     *
33
     * @param array $service
34
     */
35
    public function setService(array $service)
36
    {
37
        $this->_service = $service;
38
    }
39
40
    /**
41
     * @inheritdoc
42
     */
43
    public function init()
44
    {
45
        parent::init();
46
47
        if ($this->_service === null) {
48
            $this->_service = ['class' => DbService::class];
49
        }
50
51
        Yii::$container->set(ServiceInterface::class, $this->_service);
52
    }
53
}
54