ServiceTrait::getRecurrenceService()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 4
c 0
b 0
f 0
nc 2
nop 0
dl 0
loc 6
rs 10
1
<?php
2
3
/**
4
 * author     : forecho <[email protected]>
5
 * createTime : 2019/5/12 4:58 PM
6
 * description:
7
 */
8
9
namespace app\core\traits;
10
11
use app\core\services\AccountService;
12
use app\core\services\AnalysisService;
13
use app\core\services\CategoryService;
14
use app\core\services\RecurrenceService;
15
use app\core\services\RuleService;
16
use app\core\services\TagService;
17
use app\core\services\TelegramService;
18
use app\core\services\TransactionService;
19
use app\core\services\UploadService;
20
use app\core\services\UserService;
21
use Yii;
22
use yii\base\InvalidConfigException;
23
24
/**
25
 * Trait ServiceTrait
26
 * @property UserService $userService
27
 * @property AccountService $accountService
28
 * @property TransactionService $transactionService
29
 * @property CategoryService $categoryService
30
 * @property RuleService $ruleService
31
 * @property TelegramService $telegramService
32
 * @property AnalysisService $analysisService
33
 * @property TagService $tagService
34
 * @property RecurrenceService $recurrenceService
35
 * @property UploadService $uploadService
36
 */
37
trait ServiceTrait
38
{
39
    /**
40
     * @return UserService|object
41
     */
42
    public function getUserService()
43
    {
44
        try {
45
            return Yii::createObject(UserService::class);
46
        } catch (InvalidConfigException $e) {
47
            return new UserService();
48
        }
49
    }
50
51
52
    /**
53
     * @return AccountService|object
54
     */
55
    public function getAccountService()
56
    {
57
        try {
58
            return Yii::createObject(AccountService::class);
59
        } catch (InvalidConfigException $e) {
60
            return new AccountService();
61
        }
62
    }
63
64
    /**
65
     * @return TransactionService|object
66
     */
67
    public function getTransactionService()
68
    {
69
        try {
70
            return Yii::createObject(TransactionService::class);
71
        } catch (InvalidConfigException $e) {
72
            return new TransactionService();
73
        }
74
    }
75
76
    /**
77
     * @return CategoryService|object
78
     */
79
    public function getCategoryService()
80
    {
81
        try {
82
            return Yii::createObject(CategoryService::class);
83
        } catch (InvalidConfigException $e) {
84
            return new CategoryService();
85
        }
86
    }
87
88
    /**
89
     * @return RuleService|object
90
     */
91
    public function getRuleService()
92
    {
93
        try {
94
            return Yii::createObject(RuleService::class);
95
        } catch (InvalidConfigException $e) {
96
            return new RuleService();
97
        }
98
    }
99
100
101
    /**
102
     * @return TelegramService|object
103
     */
104
    public function getTelegramService()
105
    {
106
        try {
107
            return Yii::createObject(TelegramService::class);
108
        } catch (InvalidConfigException $e) {
109
            return new TelegramService();
110
        }
111
    }
112
113
    /**
114
     * @return AnalysisService|object
115
     */
116
    public function getAnalysisService()
117
    {
118
        try {
119
            return Yii::createObject(AnalysisService::class);
120
        } catch (InvalidConfigException $e) {
121
            return new AnalysisService();
122
        }
123
    }
124
125
    /**
126
     * @return TagService|object
127
     */
128
    public function getTagService()
129
    {
130
        try {
131
            return Yii::createObject(TagService::class);
132
        } catch (InvalidConfigException $e) {
133
            return new TagService();
134
        }
135
    }
136
137
    /**
138
     * @return RecurrenceService|object
139
     */
140
    public function getRecurrenceService()
141
    {
142
        try {
143
            return Yii::createObject(RecurrenceService::class);
144
        } catch (InvalidConfigException $e) {
145
            return new RecurrenceService();
146
        }
147
    }
148
149
    /**
150
     * @return UploadService|object
151
     */
152
    public function getUploadService()
153
    {
154
        try {
155
            return Yii::createObject(UploadService::class);
156
        } catch (InvalidConfigException $e) {
157
            return new UploadService();
158
        }
159
    }
160
}
161