Resources::checkResource()   A
last analyzed

Complexity

Conditions 4
Paths 5

Size

Total Lines 21
Code Lines 11

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 11
c 0
b 0
f 0
dl 0
loc 21
rs 9.9
cc 4
nc 5
nop 1
1
<?php
2
3
namespace CloudyCity\TencentMarketingSDK;
4
5
class Resources
6
{
7
    /**
8
     * Account management.
9
     *
10
     * @see https://developers.e.qq.com/docs/api/account
11
     */
12
    const ADVERTISER = 'advertiser';
13
14
    const QUALIFICATION = 'qualifications';
15
16
    const FUND_TRANSFER = 'fund_transfer';
17
18
    const FUNDS = 'funds';
19
20
    const FUND_STATEMENTS_DAILY = 'fund_statements_daily';
21
22
    const FUND_STATEMENTS_DETAILED = 'fund_statements_detailed';
23
24
    const WECHAT_FUNDS = 'wechat_funds';
25
26
    /**
27
     * Marketing assets.
28
     *
29
     * @see https://developers.e.qq.com/docs/api/business_assets
30
     */
31
    const PROMOTED_OBJECTS = 'promoted_objects';
32
33
    const PAGES = 'pages';
34
35
    const VIDEOS = 'videos';
36
37
    const IMAGE = 'images';
38
39
    const PRODUCT_CATALOGS = 'product_catalogs';
40
41
    const PRODUCT_ITEMS = 'product_items';
42
43
    const DYNAMIC_AD_TEMPLATES = 'dynamic_ad_templates';
44
45
    const DYNAMIC_AD_IMAGES = 'dynamic_ad_images';
46
47
    /**
48
     * Advertising management.
49
     *
50
     * @see https://developers.e.qq.com/docs/api/adsmanagement
51
     */
52
    const CAMPAIGNS = 'campaigns';
53
54
    const AD_GROUPS = 'adgroups';
55
56
    const AD_CREATIVES = 'adcreatives';
57
58
    const DYNAMIC_CREATIVES = 'dynamic_creatives';
59
60
    const ADS = 'ads';
61
62
    const TARGETINGS = 'targetings';
63
64
    const DAILY_REPORTS = 'daily_reports';
65
66
    const HOURLY_REPORTS = 'hourly_reports';
67
68
    const TARGETING_TAG_REPORTS = 'targeting_tag_reports';
69
70
    const CUSTOM_AUDIENCE_INSIGHTS = 'custom_audience_insights';
71
72
    const TRACKING_REPORTS = 'tracking_reports';
73
74
    const ECOMMERCE_ORDER = 'ecommerce_order';
75
76
    const WECHAT_LEADS = 'wechat_leads';
77
78
    const LEADS = 'leads';
79
80
    /**
81
     * Tools.
82
     *
83
     * @see https://developers.e.qq.com/docs/api/tools
84
     */
85
    const TARGETING_TAGS = 'targeting_tags';
86
87
    const AD_CREATIVE_TEMPLATES = 'adcreative_templates';
88
89
    const CAPABILITIES = 'capabilities';
90
91
    const ESTIMATION = 'estimation';
92
93
    const AD_CREATIVE_PREVIEWS = 'adcreative_previews';
94
95
    const REAL_TIME_COST = 'realtime_cost';
96
97
    const ASYNC_TASKS = 'async_tasks';
98
99
    const COMPLIANCE_VALIDATION = 'compliance_validation';
100
101
    const UNION_POSITION_PACKAGES = 'union_position_packages';
102
103
    const SPLIT_TESTS = 'split_tests';
104
105
    const DIAGNOSIS = 'diagnosis';
106
107
    const SYSTEM_STATUS = 'system_status';
108
109
    /**
110
     * User action.
111
     *
112
     * @see https://developers.e.qq.com/docs/api/user_data
113
     */
114
    const USER_ACTION_SETS = 'user_action_sets';
115
116
    const USER_ACTION_SET_REPORTS = 'user_action_set_reports';
117
118
    const USER_ACTIONS = 'user_actions';
119
120
    /**
121
     * Audiences.
122
     *
123
     * @see https://developers.e.qq.com/docs/api/audiences
124
     */
125
    const CUSTOM_AUDIENCES = 'custom_audiences';
126
127
    const CUSTOM_AUDIENCE_FILES = 'custom_audience_files';
128
129
    const CUSTOM_AUDIENCE_ESTIMATIONS = 'custom_audience_estimations';
130
131
    /**
132
     * User tags.
133
     *
134
     * @see https://developers.e.qq.com/docs/api/custom_tags
135
     */
136
    const CUSTOM_TAGS = 'custom_tags';
137
138
    const CUSTOM_TAG_FILES = 'custom_tag_files';
139
140
    /**
141
     * User property.
142
     *
143
     * @see https://developers.e.qq.com/docs/api/user_property
144
     */
145
    const USER_PROPERTY_SETS = 'user_property_sets';
146
147
    const USER_PROPERTIES = 'user_properties';
148
149
    /**
150
     * @param $resourceName
151
     *
152
     * @return bool
153
     */
154
    public static function checkResource($resourceName)
155
    {
156
        static $resourceNames = null;
157
158
        $resourceName = strval($resourceName);
159
160
        if (!$resourceName) {
161
            return false;
162
        }
163
164
        if ($resourceNames === null) {
165
            try {
166
                $reflect = new \ReflectionClass(__CLASS__);
167
168
                $resourceNames = array_flip(array_values($reflect->getConstants()));
169
            } catch (\Exception $e) {
170
                return false;
171
            }
172
        }
173
174
        return isset($resourceNames[$resourceName]);
175
    }
176
}
177