Passed
Branch master (804f63)
by Dmitry
01:12
created

my-credentials.php$1 ➔ encode()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 6
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 4
c 1
b 0
f 0
nc 2
nop 2
dl 0
loc 6
rs 10
1
<?php
2
3
/* Экземпляр класса идентификации  */
4
5
$identity = new class implements \Promopult\Integra\IdentityInterface {
6
    public function getHash(): string { return getenv('__HASH__'); }
7
    public function getCryptKey(): string { return getenv('__CRYPT_KEY__'); }
8
    public function getPartnerPath(): string { return getenv('__PARTNER_PATH__'); }
9
    public function getApiHost(): string { return getenv('__API_HOST__'); }
10
};
11
12
/* Экземпляр класса реализующий шифрование данных */
13
14
$crypt = new class implements \Promopult\Integra\CryptInterface {
15
    public function encode(string $s, string $ck): string {
16
        $r = '';
17
        for ($i = 0; $i < strlen($s); $i++) {
18
            $r .= chr(ord(substr($s, $i, 1)) + ord(substr($ck, ($i % strlen($ck)) - 1, 1)));
19
        }
20
        return base64_encode($r);
21
    }
22
    public function decode(string $string, string $key): string { return ''; }
23
};
24