Completed
Pull Request — master (#16)
by Sergii
03:56
created

DrupalKernelPlaceholder::jsonEncode()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 4
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/**
3
 * @author Sergii Bondarenko, <[email protected]>
4
 */
5
namespace Drupal\TqExtension\Cores;
6
7
use Behat\Behat\Hook\Scope\BeforeFeatureScope;
8
use Drupal\TqExtension\Context\TqContext;
9
10
class DrupalKernelPlaceholder
11
{
12
    /**
13
     * Version-related implementation of @BeforeFeature hook for TqContext.
14
     *
15
     * @param BeforeFeatureScope $scope
16
     *
17
     * @see TqContext::beforeFeature()
18
     */
19
    public static function beforeFeature(BeforeFeatureScope $scope)
1 ignored issue
show
Unused Code introduced by
The parameter $scope is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
20
    {
21
        self::requireContext(__FUNCTION__, func_get_args());
22
    }
23
24
    /**
25
     * @param string $string
26
     * @param array $arguments
27
     * @param array $options
28
     *
29
     * @return string
30
     */
31
    public static function t($string, array $arguments = [], array $options = [])
32
    {
33
        return self::requireContext(__FUNCTION__, func_get_args());
34
    }
35
36
    /**
37
     * @param string $string
38
     * @param array $arguments
39
     *
40
     * @return string
41
     */
42
    public static function formatString($string, array $arguments = [])
43
    {
44
        return self::requireContext(__FUNCTION__, func_get_args());
45
    }
46
47
    /**
48
     * @return string[]
49
     */
50
    public static function arg()
51
    {
52
        return self::requireContext(__FUNCTION__, func_get_args());
53
    }
54
55
    /**
56
     * @param string $text
57
     *   Input text.
58
     * @param array $data
59
     *   Data for replacements.
60
     * @param array $options
61
     *   Replacement configuration.
62
     *
63
     * @return string
64
     *   Processed text.
65
     */
66
    public static function tokenReplace($text, array $data = [], array $options = [])
67
    {
68
        return self::requireContext(__FUNCTION__, func_get_args());
69
    }
70
71
    /**
72
     * @return string
73
     */
74
    public static function sitePath()
75
    {
76
        return self::requireContext(__FUNCTION__, func_get_args());
77
    }
78
79
    /**
80
     * @param mixed $data
81
     *
82
     * @return string
83
     */
84
    public static function jsonEncode($data)
85
    {
86
        return self::requireContext(__FUNCTION__, func_get_args());
87
    }
88
89
    /**
90
     * @return object
91
     */
92
    public static function getCurrentUser()
93
    {
94
        return self::requireContext(__FUNCTION__, func_get_args());
95
    }
96
97
    public static function setCurrentUser($user)
98
    {
99
        self::requireContext(__FUNCTION__, func_get_args());
100
    }
101
102
    public static function setCurrentPath($path)
103
    {
104
        self::requireContext(__FUNCTION__, func_get_args());
105
    }
106
107
    /**
108
     * Locate user ID by its name.
109
     *
110
     * @param string $username
111
     *
112
     * @return int
113
     */
114
    public static function getUidByName($username)
115
    {
116
        return self::requireContext(__FUNCTION__, func_get_args());
117
    }
118
119
    /**
120
     * @param int $user_id
121
     */
122
    public static function deleteUser($user_id)
123
    {
124
        self::requireContext(__FUNCTION__, func_get_args());
125
    }
126
127
    /**
128
     * @param string $table
129
     * @param string $alias
130
     * @param array $options
131
     *
132
     * @return object
133
     */
134
    public static function selectQuery($table, $alias = null, array $options = [])
135
    {
136
        return self::requireContext(__FUNCTION__, func_get_args());
137
    }
138
139
    /**
140
     * @param string $entityType
141
     * @param string $bundle
142
     *
143
     * @return array[]
144
     *   An associative array where key - machine-name of a field and
145
     *   value - an array with two keys: "label" and "required".
146
     */
147
    public static function getFieldDefinitions($entityType, $bundle)
148
    {
149
        return self::requireContext(__FUNCTION__, func_get_args());
150
    }
151
152
    /**
153
     * Get information about database connections.
154
     *
155
     * Impossible to use $GLOBALS['databases'] in Drupal 8 since {@link https://www.drupal.org/node/2176621}.
156
     *
157
     * @param string $connection
158
     *   Connection name.
159
     *
160
     * @return array[]
161
     */
162
    public static function getDatabaseConnectionInfo($connection)
163
    {
164
        return self::requireContext(__FUNCTION__, func_get_args());
165
    }
166
167
    /**
168
     * @param string $entityType
169
     * @param int $id
170
     *
171
     * @return object|null
172
     */
173
    public static function entityLoad($entityType, $id)
174
    {
175
        return self::requireContext(__FUNCTION__, func_get_args());
176
    }
177
178
    /**
179
     * @param object $entity
180
     * @param string $fieldName
181
     *
182
     * @return bool
183
     */
184
    public static function entityHasField($entity, $fieldName)
185
    {
186
        return self::requireContext(__FUNCTION__, func_get_args());
187
    }
188
189
    /**
190
     * @param object $entity
191
     * @param string $fieldName
192
     *
193
     * @return mixed
194
     */
195
    public static function entityFieldValue($entity, $fieldName)
196
    {
197
        return self::requireContext(__FUNCTION__, func_get_args());
198
    }
199
200
    /**
201
     * Switching the mail system.
202
     *
203
     * @param bool $useTesting
204
     *   Whether testing or standard mail system should be used.
205
     */
206
    public static function switchMailSystem($useTesting)
207
    {
208
        self::requireContext(__FUNCTION__, func_get_args());
209
    }
210
211
    /**
212
     * Get a list of emails, collected by testing mail system.
213
     *
214
     * @return array
215
     */
216
    public static function getEmailMessages()
217
    {
218
        return self::requireContext(__FUNCTION__, func_get_args());
219
    }
220
221
    /**
222
     * Check existence of the content type by its machine name or title.
223
     *
224
     * @param string $contentType
225
     *   Machine name or title of the content type.
226
     *
227
     * @return string
228
     *   Machine name.
229
     */
230
    public static function getContentTypeName($contentType)
231
    {
232
        return self::requireContext(__FUNCTION__, func_get_args());
233
    }
234
235
    /**
236
     * @param string $file
237
     *   Existing file from "src/JavaScript" without ".js" extension.
238
     * @param bool $delete
239
     *   Whether injection should be deleted.
240
     */
241
    public static function injectCustomJavascript($file, $delete = false)
242
    {
243
        self::requireContext(__FUNCTION__, func_get_args());
244
    }
245
246
    /**
247
     * {@inheritdoc}
248
     */
249
    public static function drupalGetFilename($type, $name, $filename = null)
250
    {
251
        return drupal_get_filename($type, $name, $filename);
252
    }
253
254
    /**
255
     * {@inheritdoc}
256
     */
257
    public static function fileUnmanagedDelete($path)
258
    {
259
        return file_unmanaged_delete($path);
260
    }
261
262
    /**
263
     * {@inheritdoc}
264
     */
265
    public static function fileUnmanagedCopy($source, $destination = null, $replace = FILE_EXISTS_RENAME)
266
    {
267
        return file_unmanaged_copy($source, $destination, $replace);
268
    }
269
270
    /**
271
     * Require method execution from context.
272
     *
273
     * @param string $method
274
     *   The name of method.
275
     * @param array $arguments
276
     *   Method's arguments.
277
     *
278
     * @return mixed
279
     */
280
    private static function requireContext($method, array $arguments)
281
    {
282
        $context = str_replace('Kernel', DRUPAL_CORE, __CLASS__);
283
284
        if (method_exists($context, $method)) {
285
            return call_user_func_array([$context, $method], $arguments);
286
        }
287
288
        throw new \BadMethodCallException(sprintf('Method "%s" is not implemented in "%s".', $method, $context));
289
    }
290
}
291