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.

ServerItemFactory   A
last analyzed

Complexity

Total Complexity 9

Size/Duplication

Total Lines 51
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 2
Bugs 0 Features 1
Metric Value
wmc 9
c 2
b 0
f 1
lcom 0
cbo 1
dl 0
loc 51
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
B createFromObj() 0 18 5
A createFromProperties() 0 18 4
1
<?php
2
namespace SeleniumSetup\Locker;
3
4
class ServerItemFactory
5
{
6
    public static function createFromObj(\stdClass $server)
7
    {
8
        if (
9
            !isset($server->name) || 
10
            !isset($server->pid) ||
11
            !isset($server->port) ||
12
            !isset($server->configFilePath)
13
        ) {
14
            throw new \Exception('Server instance cannot be created. Missing keys.');
15
        }
16
        
17
        return (new ServerItem())
18
            ->setName($server->name)
19
            ->setPid($server->pid)
20
            ->setPort($server->port)
21
            ->setConfigFilePath($server->configFilePath)
22
            ->setDateStarted(date(ServerItem::DATE_FORMAT));
23
    }
24
25
    /**
26
     * The PID is no longer required to be greater than zero. (when PID = zero, this usually means it's stopped).
27
     *
28
     * @param string $name
29
     * @param int $pid
30
     * @param int $port
31
     * @param string $configFilePath
32
     *
33
     * @return ServerItem
34
     * @throws \Exception
35
     */
36
    public static function createFromProperties($name, $pid, $port, $configFilePath)
37
    {
38
        if (
39
            empty($name) ||
40
            // empty($pid) ||
0 ignored issues
show
Unused Code Comprehensibility introduced by
72% of this comment could be valid code. Did you maybe forget this after debugging?

Sometimes obsolete code just ends up commented out instead of removed. In this case it is better to remove the code once you have checked you do not need it.

The code might also have been commented out for debugging purposes. In this case it is vital that someone uncomments it again or your project may behave in very unexpected ways in production.

This check looks for comments that seem to be mostly valid code and reports them.

Loading history...
41
            empty($port) ||
42
            empty($configFilePath)
43
        ) {
44
            throw new \Exception('Server instance cannot be created. Missing values.');
45
        }
46
47
        return (new ServerItem())
48
            ->setName($name)
49
            ->setPid($pid)
50
            ->setPort($port)
51
            ->setConfigFilePath($configFilePath)
52
            ->setDateStarted(date(ServerItem::DATE_FORMAT));
53
    }
54
}