UPS::__construct()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
nc 1
nop 0
dl 0
loc 5
rs 9.4285
c 0
b 0
f 0
1
<?php
2
/**
3
 * Basic UPS Class
4
 *
5
 * PHP version 5
6
 *
7
 * @category  PHP
8
 * @package   PSI_UPS
9
 * @author    Michael Cramer <[email protected]>
10
 * @copyright 2009 phpSysInfo
11
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
12
 * @version   SVN: $Id: class.ups.inc.php 661 2012-08-27 11:26:39Z namiltd $
13
 * @link      http://phpsysinfo.sourceforge.net
14
 */
15
 /**
16
 * Basic UPS functions for all UPS classes
17
 *
18
 * @category  PHP
19
 * @package   PSI_UPS
20
 * @author    Michael Cramer <[email protected]>
21
 * @copyright 2009 phpSysInfo
22
 * @license   http://opensource.org/licenses/gpl-2.0.php GNU General Public License
23
 * @version   Release: 3.0
24
 * @link      http://phpsysinfo.sourceforge.net
25
 */
26
abstract class UPS implements PSI_Interface_UPS
0 ignored issues
show
Coding Style Compatibility introduced by
PSR1 recommends that each class must be in a namespace of at least one level to avoid collisions.

You can fix this by adding a namespace to your class:

namespace YourVendor;

class YourClass { }

When choosing a vendor namespace, try to pick something that is not too generic to avoid conflicts with other libraries.

Loading history...
27
{
28
    /**
29
     * object for error handling
30
     *
31
     * @var Error
32
     */
33
    public $error;
34
35
    /**
36
     * main object for ups information
37
     *
38
     * @var UPSInfo
39
     */
40
    protected $upsinfo;
41
42
    /**
43
     * build the global Error object
44
     */
45
    public function __construct()
46
    {
47
        $this->error = PSI_Error::singleton();
0 ignored issues
show
Bug introduced by
Are you sure the assignment to $this->error is correct as \PSI_Error::singleton() (which targets PSI_Error::singleton()) seems to always return null.

This check looks for function or method calls that always return null and whose return value is assigned to a variable.

class A
{
    function getObject()
    {
        return null;
    }

}

$a = new A();
$object = $a->getObject();

The method getObject() can return nothing but null, so it makes no sense to assign that value to a variable.

The reason is most likely that a function or method is imcomplete or has been reduced for debug purposes.

Loading history...
48
        $this->upsinfo = new UPSInfo();
49
    }
50
51
    /**
52
     * build and return the ups information
53
     *
54
     * @see PSI_Interface_UPS::getUPSInfo()
55
     *
56
     * @return UPSInfo
57
     */
58
    final public function getUPSInfo()
59
    {
60
        $this->build();
61
62
        return $this->upsinfo;
63
    }
64
}
65