Completed
Branch master (b7a0b6)
by Adrian
04:26 queued 02:31
created

AbstractStringRule::getStringLength()   A

Complexity

Conditions 4
Paths 2

Size

Total Lines 12
Code Lines 7

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 7
CRAP Score 4.0312

Importance

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