GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

fieldTextarea   F
last analyzed

Complexity

Total Complexity 61

Size/Duplication

Total Lines 391
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 152
c 1
b 0
f 0
dl 0
loc 391
rs 3.52
wmc 61

20 Methods

Rating   Name   Duplication   Size   Complexity  
A canFilter() 0 3 1
A canPrePopulate() 0 3 1
A findDefaults() 0 4 2
A createTable() 0 4 1
A __replaceAmpersands() 0 3 1
A displaySettingsPanel() 0 17 1
A getExportModes() 0 7 1
A prepareImportValue() 0 12 3
A buildDSRetrievalSQL() 0 26 4
A __applyFormatting() 0 21 5
B prepareExportValue() 0 28 10
A __construct() 0 9 1
A processRawFieldData() 0 20 3
A getImportModes() 0 5 1
B appendFormattedElement() 0 29 9
A fetchIncludableElements() 0 11 2
A commit() 0 21 4
A checkPostFieldData() 0 15 4
A displayPublishPanel() 0 37 6
A getExampleFormMarkup() 0 6 1

How to fix   Complexity   

Complex Class

Complex classes like fieldTextarea often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.

Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.

While breaking up the class, it is a good idea to analyze how other classes use fieldTextarea, and based on these observations, apply Extract Interface, too.

1
<?php
2
3
/**
4
 * @package toolkit
5
 */
6
7
/**
8
 * A simple Textarea field that essentially maps to HTML's `<textarea/>`.
9
 */
10
class fieldTextarea extends Field implements ExportableField, ImportableField
0 ignored issues
show
Coding Style introduced by
This class is not in CamelCase format.

Classes in PHP are usually named in CamelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. The whole name starts with a capital letter as well.

Thus the name database provider becomes DatabaseProvider.

Loading history...
11
{
12
    public function __construct()
13
    {
14
        parent::__construct();
15
        $this->_name = __('Textarea');
0 ignored issues
show
Bug Best Practice introduced by
The property _name does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
16
        $this->_required = true;
17
18
        // Set default
19
        $this->set('show_column', 'no');
20
        $this->set('required', 'no');
21
    }
22
23
    /*-------------------------------------------------------------------------
24
        Definition:
25
    -------------------------------------------------------------------------*/
26
27
    public function canFilter()
28
    {
29
        return true;
30
    }
31
    
32
    public function canPrePopulate()
33
    {
34
        return true;
35
    }
36
    
37
    /*-------------------------------------------------------------------------
38
        Setup:
39
    -------------------------------------------------------------------------*/
40
41
    public function createTable()
42
    {
43
        return Symphony::Database()->query(
44
            "CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . $this->get('id') . "` (
0 ignored issues
show
Coding Style Comprehensibility introduced by
The string literal CREATE TABLE IF NOT EXISTS `tbl_entries_data_ does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Coding Style Comprehensibility introduced by
The string literal ` (\n `id` ...OLLATE=utf8_unicode_ci; does not require double quotes, as per coding-style, please use single quotes.

PHP provides two ways to mark string literals. Either with single quotes 'literal' or with double quotes "literal". The difference between these is that string literals in double quotes may contain variables with are evaluated at run-time as well as escape sequences.

String literals in single quotes on the other hand are evaluated very literally and the only two characters that needs escaping in the literal are the single quote itself (\') and the backslash (\\). Every other character is displayed as is.

Double quoted string literals may contain other variables or more complex escape sequences.

<?php

$singleQuoted = 'Value';
$doubleQuoted = "\tSingle is $singleQuoted";

print $doubleQuoted;

will print an indented: Single is Value

If your string literal does not contain variables or escape sequences, it should be defined using single quotes to make that fact clear.

For more information on PHP string literals and available escape sequences see the PHP core documentation.

Loading history...
Bug introduced by
Are you sure $this->get('id') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

44
            "CREATE TABLE IF NOT EXISTS `tbl_entries_data_" . /** @scrutinizer ignore-type */ $this->get('id') . "` (
Loading history...
45
              `id` int(11) unsigned NOT null auto_increment,
46
              `entry_id` int(11) unsigned NOT null,
47
              `value` MEDIUMTEXT,
48
              `value_formatted` MEDIUMTEXT,
49
              PRIMARY KEY  (`id`),
50
              UNIQUE KEY `entry_id` (`entry_id`),
51
              FULLTEXT KEY `value` (`value`)
52
            ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;"
53
        );
54
    }
55
56
/*-------------------------------------------------------------------------
57
    Utilities:
58
-------------------------------------------------------------------------*/
59
60
    protected function __applyFormatting($data, $validate = false, &$errors = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$validate" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$validate"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$errors" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$errors"; expected 0 but found 1
Loading history...
61
    {
62
        $result = '';
63
64
        if ($this->get('formatter')) {
65
            $formatter = TextformatterManager::create($this->get('formatter'));
0 ignored issues
show
Bug introduced by
It seems like $this->get('formatter') can also be of type array; however, parameter $handle of TextformatterManager::create() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

65
            $formatter = TextformatterManager::create(/** @scrutinizer ignore-type */ $this->get('formatter'));
Loading history...
66
            $result = $formatter->run($data);
67
        }
68
69
        if ($validate === true) {
70
            if (!General::validateXML($result, $errors, false, new XsltProcess)) {
71
                $result = html_entity_decode($result, ENT_QUOTES, 'UTF-8');
72
                $result = $this->__replaceAmpersands($result);
73
74
                if (!General::validateXML($result, $errors, false, new XsltProcess)) {
75
                    return false;
76
                }
77
            }
78
        }
79
80
        return $result;
81
    }
82
83
    private function __replaceAmpersands($value)
84
    {
85
        return preg_replace('/&(?!(#[0-9]+|#x[0-9a-f]+|amp|lt|gt);)/i', '&amp;', trim($value));
86
    }
87
88
    /*-------------------------------------------------------------------------
89
        Settings:
90
    -------------------------------------------------------------------------*/
91
92
    public function findDefaults(array &$settings)
93
    {
94
        if (!isset($settings['size'])) {
95
            $settings['size'] = 15;
96
        }
97
    }
98
99
    public function displaySettingsPanel(XMLElement &$wrapper, $errors = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$errors" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$errors"; expected 0 but found 1
Loading history...
100
    {
101
        parent::displaySettingsPanel($wrapper, $errors);
102
103
        // Textarea Size
104
        $label = Widget::Label(__('Number of default rows'));
105
        $label->setAttribute('class', 'column');
106
        $input = Widget::Input('fields['.$this->get('sortorder').'][size]', (string)$this->get('size'));
0 ignored issues
show
Bug introduced by
Are you sure $this->get('sortorder') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

106
        $input = Widget::Input('fields['./** @scrutinizer ignore-type */ $this->get('sortorder').'][size]', (string)$this->get('size'));
Loading history...
107
        $label->appendChild($input);
108
109
        $div = new XMLElement('div', null, array('class' => 'two columns'));
110
        $div->appendChild($label);
111
        $div->appendChild($this->buildFormatterSelect($this->get('formatter'), 'fields['.$this->get('sortorder').'][formatter]', __('Text Formatter')));
0 ignored issues
show
Bug introduced by
It seems like $this->get('formatter') can also be of type array; however, parameter $selected of Field::buildFormatterSelect() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

111
        $div->appendChild($this->buildFormatterSelect(/** @scrutinizer ignore-type */ $this->get('formatter'), 'fields['.$this->get('sortorder').'][formatter]', __('Text Formatter')));
Loading history...
112
        $wrapper->appendChild($div);
113
114
        // Requirements and table display
115
        $this->appendStatusFooter($wrapper);
116
    }
117
118
    public function commit()
119
    {
120
        if (!parent::commit()) {
121
            return false;
122
        }
123
124
        $id = $this->get('id');
125
126
        if ($id === false) {
127
            return false;
128
        }
129
130
        $fields = array();
131
132
        if ($this->get('formatter') != 'none') {
133
            $fields['formatter'] = $this->get('formatter');
134
        }
135
136
        $fields['size'] = $this->get('size');
137
138
        return FieldManager::saveSettings($id, $fields);
0 ignored issues
show
Bug introduced by
It seems like $id can also be of type array; however, parameter $field_id of FieldManager::saveSettings() does only seem to accept integer, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

138
        return FieldManager::saveSettings(/** @scrutinizer ignore-type */ $id, $fields);
Loading history...
139
    }
140
141
    /*-------------------------------------------------------------------------
142
        Publish:
143
    -------------------------------------------------------------------------*/
144
145
    public function displayPublishPanel(XMLElement &$wrapper, $data = null, $flagWithError = null, $fieldnamePrefix = null, $fieldnamePostfix = null, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$data" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$data"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$flagWithError" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$flagWithError"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$fieldnamePrefix" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$fieldnamePrefix"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$fieldnamePostfix" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$fieldnamePostfix"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
146
    {
147
        $label = Widget::Label($this->get('label'));
0 ignored issues
show
Bug introduced by
It seems like $this->get('label') can also be of type array; however, parameter $name of Widget::Label() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

147
        $label = Widget::Label(/** @scrutinizer ignore-type */ $this->get('label'));
Loading history...
148
149
        if ($this->get('required') !== 'yes') {
150
            $label->appendChild(new XMLElement('i', __('Optional')));
151
        }
152
153
        $value = isset($data['value']) ? $data['value'] : null;
154
        $textarea = Widget::Textarea('fields'.$fieldnamePrefix.'['.$this->get('element_name').']'.$fieldnamePostfix, (int)$this->get('size'), 50, (strlen($value) != 0 ? General::sanitizeDouble($value) : null));
0 ignored issues
show
Coding Style introduced by
Inline shorthand IF statement requires brackets around comparison
Loading history...
Bug introduced by
Are you sure $this->get('element_name') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

154
        $textarea = Widget::Textarea('fields'.$fieldnamePrefix.'['./** @scrutinizer ignore-type */ $this->get('element_name').']'.$fieldnamePostfix, (int)$this->get('size'), 50, (strlen($value) != 0 ? General::sanitizeDouble($value) : null));
Loading history...
155
156
        if ($this->get('formatter') != 'none') {
157
            $textarea->setAttribute('class', $this->get('formatter'));
0 ignored issues
show
Bug introduced by
It seems like $this->get('formatter') can also be of type array; however, parameter $value of XMLElement::setAttribute() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

157
            $textarea->setAttribute('class', /** @scrutinizer ignore-type */ $this->get('formatter'));
Loading history...
158
        }
159
160
        /**
161
         * Allows developers modify the textarea before it is rendered in the publish forms
162
         *
163
         * @delegate ModifyTextareaFieldPublishWidget
164
         * @param string $context
165
         * '/backend/'
166
         * @param Field $field
167
         * @param Widget $label
168
         * @param Widget $textarea
169
         */
170
        Symphony::ExtensionManager()->notifyMembers('ModifyTextareaFieldPublishWidget', '/backend/', array(
171
            'field' => &$this,
172
            'label' => &$label,
173
            'textarea' => &$textarea
174
        ));
175
176
        $label->appendChild($textarea);
177
178
        if ($flagWithError != null) {
179
            $wrapper->appendChild(Widget::Error($label, $flagWithError));
180
        } else {
181
            $wrapper->appendChild($label);
182
        }
183
    }
184
185
    public function checkPostFieldData($data, &$message, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
186
    {
187
        $message = null;
188
189
        if ($this->get('required') === 'yes' && strlen(trim($data)) == 0) {
190
            $message = __('‘%s’ is a required field.', array($this->get('label')));
191
            return self::__MISSING_FIELDS__;
192
        }
193
194
        if ($this->__applyFormatting($data, true, $errors) === false) {
195
            $message = __('‘%s’ contains invalid XML.', array($this->get('label'))) . ' ' . __('The following error was returned:') . ' <code>' . $errors[0]['message'] . '</code>';
196
            return self::__INVALID_FIELDS__;
197
        }
198
199
        return self::__OK__;
200
    }
201
202
    public function processRawFieldData($data, &$status, &$message = null, $simulate = false, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$message" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$message"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$simulate" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$simulate"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
203
    {
204
        $status = self::__OK__;
205
206
        if (strlen(trim($data)) == 0) {
207
            return array();
208
        }
209
210
        $result = array(
211
            'value' => $data
212
        );
213
214
        $result['value_formatted'] = $this->__applyFormatting($data, true, $errors);
215
216
        if ($result['value_formatted'] === false) {
217
            // Run the formatter again, but this time do not validate. We will sanitize the output
218
            $result['value_formatted'] = General::sanitize($this->__applyFormatting($data));
219
        }
220
221
        return $result;
222
    }
223
224
    /*-------------------------------------------------------------------------
225
        Output:
226
    -------------------------------------------------------------------------*/
227
228
    public function fetchIncludableElements()
229
    {
230
        if ($this->get('formatter')) {
231
            return array(
232
                $this->get('element_name') . ': formatted',
0 ignored issues
show
Bug introduced by
Are you sure $this->get('element_name') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

232
                /** @scrutinizer ignore-type */ $this->get('element_name') . ': formatted',
Loading history...
233
                $this->get('element_name') . ': unformatted'
234
            );
235
        }
236
237
        return array(
238
            $this->get('element_name')
239
        );
240
    }
241
242
    public function appendFormattedElement(XMLElement &$wrapper, $data, $encode = false, $mode = null, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$encode" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$encode"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$mode" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$mode"; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
243
    {
244
        $attributes = array();
245
246
        if (!is_null($mode)) {
247
            $attributes['mode'] = $mode;
248
        }
249
250
        if ($mode == 'formatted') {
251
            if ($this->get('formatter') && isset($data['value_formatted'])) {
252
                $value = $data['value_formatted'];
253
            } else {
254
                $value = $this->__replaceAmpersands($data['value']);
255
            }
256
257
            $wrapper->appendChild(
258
                new XMLElement(
259
                    $this->get('element_name'),
0 ignored issues
show
Bug introduced by
It seems like $this->get('element_name') can also be of type array; however, parameter $name of XMLElement::__construct() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

259
                    /** @scrutinizer ignore-type */ $this->get('element_name'),
Loading history...
260
                    ($encode ? General::sanitize($value) : $value),
0 ignored issues
show
Coding Style introduced by
Inline shorthand IF statement requires brackets around comparison
Loading history...
261
                    $attributes
262
                )
263
            );
264
        } elseif ($mode == null || $mode == 'unformatted') {
265
            $value = !empty($data['value'])
266
                ? sprintf('<![CDATA[%s]]>', str_replace(']]>', ']]]]><![CDATA[>', $data['value']))
0 ignored issues
show
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
267
                : $data['value'];
268
269
            $wrapper->appendChild(
270
                new XMLElement($this->get('element_name'), $value, $attributes)
271
            );
272
        }
273
    }
274
275
    /*-------------------------------------------------------------------------
276
        Import:
277
    -------------------------------------------------------------------------*/
278
279
    public function getImportModes()
280
    {
281
        return array(
282
            'getValue' =>       ImportableField::STRING_VALUE,
283
            'getPostdata' =>    ImportableField::ARRAY_VALUE
284
        );
285
    }
286
287
    public function prepareImportValue($data, $mode, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
288
    {
289
        $message = $status = null;
290
        $modes = (object)$this->getImportModes();
291
292
        if ($mode === $modes->getValue) {
293
            return $data;
294
        } elseif ($mode === $modes->getPostdata) {
295
            return $this->processRawFieldData($data, $status, $message, true, $entry_id);
296
        }
297
298
        return null;
299
    }
300
301
    /*-------------------------------------------------------------------------
302
        Export:
303
    -------------------------------------------------------------------------*/
304
305
    /**
306
     * Return a list of supported export modes for use with `prepareExportValue`.
307
     *
308
     * @return array
309
     */
310
    public function getExportModes()
311
    {
312
        return array(
313
            'getHandle' =>      ExportableField::HANDLE,
314
            'getFormatted' =>   ExportableField::FORMATTED,
315
            'getUnformatted' => ExportableField::UNFORMATTED,
316
            'getPostdata' =>    ExportableField::POSTDATA
317
        );
318
    }
319
320
    /**
321
     * Give the field some data and ask it to return a value using one of many
322
     * possible modes.
323
     *
324
     * @param mixed $data
325
     * @param integer $mode
326
     * @param integer $entry_id
327
     * @return string|null
328
     */
329
    public function prepareExportValue($data, $mode, $entry_id = null)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$entry_id" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$entry_id"; expected 0 but found 1
Loading history...
330
    {
331
        $modes = (object)$this->getExportModes();
332
333
        // Export handles:
334
        if ($mode === $modes->getHandle) {
335
            if (isset($data['handle'])) {
336
                return $data['handle'];
337
            } elseif (isset($data['value'])) {
338
                return Lang::createHandle($data['value']);
339
            }
340
341
            // Export unformatted:
342
        } elseif ($mode === $modes->getUnformatted || $mode === $modes->getPostdata) {
343
            return isset($data['value'])
344
                ? $data['value']
0 ignored issues
show
Coding Style introduced by
Inline shorthand IF statement must be declared on a single line
Loading history...
345
                : null;
346
347
            // Export formatted:
348
        } elseif ($mode === $modes->getFormatted) {
349
            if (isset($data['value_formatted'])) {
350
                return $data['value_formatted'];
351
            } elseif (isset($data['value'])) {
352
                return General::sanitize($data['value']);
353
            }
354
        }
355
356
        return null;
357
    }
358
359
    /*-------------------------------------------------------------------------
360
        Filtering:
361
    -------------------------------------------------------------------------*/
362
363
    public function buildDSRetrievalSQL($data, &$joins, &$where, $andOperation = false)
0 ignored issues
show
Coding Style introduced by
Incorrect spacing between argument "$andOperation" and equals sign; expected 0 but found 1
Loading history...
Coding Style introduced by
Incorrect spacing between default value and equals sign for argument "$andOperation"; expected 0 but found 1
Loading history...
364
    {
365
        $field_id = $this->get('id');
366
367
        if (self::isFilterRegex($data[0])) {
368
            $this->buildRegexSQL($data[0], array('value'), $joins, $where);
369
        } elseif (self::isFilterSQL($data[0])) {
370
            $this->buildFilterSQL($data[0], array('value'), $joins, $where);
371
        } else {
372
            if (is_array($data)) {
373
                $data = $data[0];
374
            }
375
376
            $this->_key++;
377
            $data = $this->cleanValue($data);
378
            $joins .= "
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $field_id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
379
                LEFT JOIN
380
                    `tbl_entries_data_{$field_id}` AS t{$field_id}_{$this->_key}
381
                    ON (e.id = t{$field_id}_{$this->_key}.entry_id)
382
            ";
383
            $where .= "
0 ignored issues
show
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $field_id instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $this instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
Coding Style Best Practice introduced by
As per coding-style, please use concatenation or sprintf for the variable $data instead of interpolation.

It is generally a best practice as it is often more readable to use concatenation instead of interpolation for variables inside strings.

// Instead of
$x = "foo $bar $baz";

// Better use either
$x = "foo " . $bar . " " . $baz;
$x = sprintf("foo %s %s", $bar, $baz);
Loading history...
384
                AND MATCH (t{$field_id}_{$this->_key}.value) AGAINST ('{$data}' IN BOOLEAN MODE)
385
            ";
386
        }
387
388
        return true;
389
    }
390
391
    /*-------------------------------------------------------------------------
392
        Events:
393
    -------------------------------------------------------------------------*/
394
395
    public function getExampleFormMarkup()
396
    {
397
        $label = Widget::Label($this->get('label'));
0 ignored issues
show
Bug introduced by
It seems like $this->get('label') can also be of type array; however, parameter $name of Widget::Label() does only seem to accept string, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

397
        $label = Widget::Label(/** @scrutinizer ignore-type */ $this->get('label'));
Loading history...
398
        $label->appendChild(Widget::Textarea('fields['.$this->get('element_name').']', (int)$this->get('size'), 50));
0 ignored issues
show
Bug introduced by
Are you sure $this->get('element_name') of type array|mixed|null can be used in concatenation? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

398
        $label->appendChild(Widget::Textarea('fields['./** @scrutinizer ignore-type */ $this->get('element_name').']', (int)$this->get('size'), 50));
Loading history...
399
400
        return $label;
401
    }
402
}
403