Completed
Push — master ( aeb11c...f98da5 )
by Adrian
02:32
created

AbstractStringRule::getStringLength()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 10
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 4.074

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 10
ccs 5
cts 6
cp 0.8333
rs 9.2
cc 4
eloc 6
nc 2
nop 1
crap 4.074
1
<?php
2
3
namespace Sirius\Validation\Rule;
4
5
abstract class AbstractStringRule extends AbstractRule
6
{
7
8 9
    protected function getStringLength($str)
9
    {
10 9
        if (function_exists('mb_strlen')) {
11 9
            return mb_strlen($str,
12 9
                (isset($this->options['encoding']) && $this->options['encoding']) ?
13 9
                    $this->options['encoding'] : mb_internal_encoding());
14
        }
15
16
        return strlen($str);
17
    }
18
}