Crockford   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 3
dl 0
loc 24
ccs 4
cts 4
cp 1
rs 10
c 1
b 0
f 0
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A encode() 0 3 1
A decode() 0 3 1
1
<?php
2
3
/*
4
 * This file is part of ocubom/base-convert
5
 *
6
 * © Oscar Cubo Medina <https://ocubom.github.io>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Ocubom\Math;
13
14
use Ocubom\Math\Base\Crockford as BaseCrockford;
0 ignored issues
show
Bug introduced by
The type Ocubom\Math\Base\Crockford was not found. Maybe you did not declare it correctly or list all dependencies?

The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g. excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:

filter:
    dependency_paths: ["lib/*"]

For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths

Loading history...
15
16
abstract class Crockford
17
{
18
    /**
19
     * Convert a number to crockford base32 encoding.
20
     *
21
     * @param int|string               $number   The number to convert
22
     * @param BaseInterface|int|string $base     The base of $number
23
     * @param bool                     $checksum Include a checksum
24
     */
25 16
    final public static function encode($number, $base, bool $checksum = false): string
26
    {
27 16
        return Base::convert($number, $base, new BaseCrockford($checksum));
28
    }
29
30
    /**
31
     * Convert a number from crockford base32 encoding.
32
     *
33
     * @param int|string               $number   The crockford number to convert
34
     * @param BaseInterface|int|string $base     The base to covert $number
35
     * @param bool                     $checksum Include a checksum
36
     */
37 51
    final public static function decode($number, $base, bool $checksum = false): string
38
    {
39 51
        return Base::convert($number, new BaseCrockford($checksum), $base);
40
    }
41
}
42