GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

MachineId   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 55
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 34
c 1
b 0
f 1
dl 0
loc 55
rs 10
wmc 2

1 Method

Rating   Name   Duplication   Size   Complexity  
A generate() 0 48 2
1
<?php
2
/**
3
 * This file is part of the O2System Framework package.
4
 *
5
 * For the full copyright and license information, please view the LICENSE
6
 * file that was distributed with this source code.
7
 *
8
 * @author         Steeve Andrian Salim
9
 * @copyright      Copyright (c) Steeve Andrian Salim
10
 */
11
12
/**
13
 * Created by PhpStorm.
14
 * User: steevenz
15
 * Date: 05/04/18
16
 * Time: 10.11
17
 */
18
19
namespace O2System\Security\Generators;
20
21
use O2System\Kernel\Http\Message\Uri;
22
23
/**
24
 * Class MachineId
25
 *
26
 * Generate Machine ID based on System Metadata information in UUID (Universally Unique Identifier) format.
27
 *
28
 * @package O2System\Security\Generators
29
 */
30
class MachineId
31
{
32
    /**
33
     * MachineId::generate
34
     *
35
     * @return string
36
     */
37
    public static function generate()
38
    {
39
        if (class_exists('O2System\Filesystem\System')) {
40
            $system = new \O2System\Filesystem\System();
0 ignored issues
show
Bug introduced by
The type O2System\Filesystem\System 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...
41
42
            $metadata = [
43
                'machine'         => $system->getMachine(),
44
                'operatingSystem' => [
45
                    'name'    => $system->getName(),
46
                    'version' => $system->getVersion(),
47
                    'release' => $system->getRelease(),
48
                ],
49
                'hostname'        => $system->getHostname(),
50
                'cpuCores'        => $system->getCpuCores(),
51
                'macAddress'      => $system->getMacAddress(),
52
            ];
53
        } else {
54
            $metadata = [
55
                'machine'         => php_uname('m'),
56
                'operatingSystem' => [
57
                    'name'    => php_uname('s'),
58
                    'version' => php_uname('v'),
59
                    'release' => php_uname('r'),
60
                ],
61
                'hostname'        => php_uname('n'),
62
                'cpuCores'        => 1,
63
                'macAddress'      => implode(':', str_split(substr(md5('none'), 0, 12), 2)),
64
            ];
65
        }
66
67
        $uri = new Uri();
68
69
        $metadata[ 'domain' ] = $uri->getHost();
70
        $metadata[ 'ipAddress' ] = $_SERVER[ 'SERVER_ADDR' ];
71
72
        $string = json_encode($metadata);
73
        $string = md5($string);
74
75
        // Converts to UUID (Universally Unique Identifier)
76
        $parts[] = substr($string, 0, 8);
0 ignored issues
show
Comprehensibility Best Practice introduced by
$parts was never initialized. Although not strictly required by PHP, it is generally a good practice to add $parts = array(); before regardless.
Loading history...
77
        $parts[] = substr($string, 8, 4);
78
        $parts[] = substr($string, 12, 4);
79
        $parts[] = substr($string, 16, 4);
80
        $parts[] = substr($string, 20, 12);
81
82
        $parts = array_map('strtoupper', $parts);
83
84
        return implode('-', $parts);
85
    }
86
}