Completed
Pull Request — develop (#537)
by Agel_Nash
05:20
created

PHPCOMPAT::__construct()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
nc 1
nop 0
dl 0
loc 3
rs 10
c 0
b 0
f 0
1
<?php
2
3
/**
4
 * @TODO file_put_contents(), strftime(), mb_*()
0 ignored issues
show
Coding Style introduced by
Comment refers to a TODO task

This check looks TODO comments that have been left in the code.

``TODO``s show that something is left unfinished and should be attended to.

Loading history...
5
 */
6
class PHPCOMPAT
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
7
{
8
    /**
9
     * @param string $str
10
     * @param int $flags
11
     * @param string $encode
12
     * @return string
13
     */
14
    public function htmlspecialchars($str = '', $flags = ENT_COMPAT, $encode = '')
15
    {
16
        global $modx;
17
18
        if ($str == '') {
19
            return '';
20
        }
21
22
        if ($encode == '') {
23
            $encode = $modx->config['modx_charset'];
24
        }
25
26
        $ent_str = htmlspecialchars($str, $flags, $encode);
27
28
        if (!empty($str) && empty($ent_str)) {
29
            $detect_order = implode(',', mb_detect_order());
30
            $ent_str = mb_convert_encoding($str, $encode, $detect_order);
31
        }
32
33
        return $ent_str;
34
    }
35
}
36