Completed
Push — master ( cf38d9...2ecc50 )
by Rob
01:50
created

Resources   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Test Coverage

Coverage 61.53%

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 0
dl 0
loc 33
ccs 8
cts 13
cp 0.6153
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getReplacementValue() 0 4 1
A setReplacementValue() 0 4 1
A _filter_attributes() 0 15 4
1
<?php
2
3
namespace devtoolboxuk\soteria\voku\Resources;
4
class Resources
0 ignored issues
show
Coding Style introduced by
The property $_replacement is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
The property $_spacing_regex is not named in camelCase.

This check marks property names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
5
{
6
7
    protected $_replacement = '';
8
9
    protected $_spacing_regex = '(?:\s|"|\042|\'|\047|\+|&#x09;|&#x0[A-F];|%0a)*+';
10
11
    protected function getReplacementValue()
12
    {
13
        return $this->_replacement;
14
    }
15
16
    function setReplacementValue($data)
0 ignored issues
show
Best Practice introduced by
It is generally recommended to explicitly declare the visibility for methods.

Adding explicit visibility (private, protected, or public) is generally recommend to communicate to other developers how, and from where this method is intended to be used.

Loading history...
Comprehensibility Best Practice introduced by
It is recommend to declare an explicit visibility for setReplacementValue.

Generally, we recommend to declare visibility for all methods in your source code. This has the advantage of clearly communication to other developers, and also yourself, how this method should be consumed.

If you are not sure which visibility to choose, it is a good idea to start with the most restrictive visibility, and then raise visibility as needed, i.e. start with private, and only raise it to protected if a sub-class needs to have access, or public if an external class needs access.

Loading history...
17
    {
18
        $this->_replacement = $data;
19
    }
20
21 6
    protected function _filter_attributes($str)
0 ignored issues
show
Coding Style Naming introduced by
The method _filter_attributes is not named in camelCase.

This check marks method names that have not been written in camelCase.

In camelCase names are written without any punctuation, the start of each new word being marked by a capital letter. Thus the name database connection string becomes databaseConnectionString.

Loading history...
Coding Style introduced by
Method name "Resources::_filter_attributes" is not in camel caps format
Loading history...
22
    {
23 6
        if ($str === '') {
24 2
            return '';
25
        }
26
27 6
        $out = '';
28 6
        if (preg_match_all('#\s*[\\p{L}0-9_\-\[\]]+\s*=\s*("|\042|\'|\047)(?:[^\\1]*?)\\1#ui', $str, $matches)) {
29 6
            foreach ($matches[0] as $match) {
30 6
                $out .= $match;
31
            }
32
        }
33
34 6
        return $out;
35
    }
36
}