Completed
Push — master ( 7194ef...e1b380 )
by Michael
01:30
created

Rot128   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 19
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A flip() 0 10 2
1
<?php declare(strict_types=1);
2
3
/**
4
 * Rot128.php
5
 *
6
 * PHP version 7
7
 *
8
 * @category Dcrypt
9
 * @package  Dcrypt
10
 * @author   Michael Meyer (mmeyer2k) <[email protected]>
11
 * @license  http://opensource.org/licenses/MIT The MIT License (MIT)
12
 * @link     https://github.com/mmeyer2k/dcrypt
13
 */
14
15
namespace Dcrypt;
16
17
class Rot128
18
{
19
    /**
20
     * Rot-128 encode a binary string with strtr.
21
     *
22
     * @param string $input
23
     * @return string
24
     */
25
    public static function flip(string $input): string
26
    {
27
        $translation = [];
28
29
        foreach (\range(0, 255) as $r) {
30
            $translation[chr($r)] = chr($r + 128);
31
        }
32
33
        return strtr($input, $translation);
34
    }
35
}