LeftRedactor   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 14
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 2
eloc 5
dl 0
loc 14
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A redact() 0 9 2
1
<?php
2
3
namespace OwenIt\Auditing\Redactors;
4
5
class LeftRedactor implements \OwenIt\Auditing\Contracts\AttributeRedactor
6
{
7
    /**
8
     * {@inheritdoc}
9
     */
10
    public static function redact($value): string
11
    {
12
        $total = strlen($value);
13
        $tenth = (int) ceil($total / 10);
14
15
        // Make sure single character strings get redacted
16
        $length = ($total > $tenth) ? ($total - $tenth) : 1;
17
18
        return str_pad(substr($value, $length), $total, '#', STR_PAD_LEFT);
19
    }
20
}
21