Completed
Push — master ( d45ca1...554243 )
by Adrian
01:42
created

AbstractStringRule   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 15
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 85.71%

Importance

Changes 0
Metric Value
wmc 4
lcom 1
cbo 1
dl 0
loc 15
ccs 6
cts 7
cp 0.8571
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A getStringLength() 0 12 4
1
<?php
2
declare(strict_types=1);
3
4
namespace Sirius\Validation\Rule;
5
6
abstract class AbstractStringRule extends AbstractRule
7
{
8 9
    protected function getStringLength($str)
9
    {
10 9
        if (function_exists('mb_strlen')) {
11 9
            return mb_strlen(
12 9
                $str,
13 9
                (isset($this->options['encoding']) && $this->options['encoding']) ?
14 9
                $this->options['encoding'] : mb_internal_encoding()
15
            );
16
        }
17
18
        return strlen($str);
19
    }
20
}
21