Test Failed
Push — master ( 5d347f...d6f93a )
by Stefan
07:03
created

DeploymentClassic::__construct()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 9
Code Lines 6

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 9
rs 10
c 0
b 0
f 0
cc 2
nc 2
nop 2
1
<?php
2
3
/*
4
 * *****************************************************************************
5
 * Contributions to this work were made on behalf of the GÉANT project, a 
6
 * project that has received funding from the European Union’s Framework 
7
 * Programme 7 under Grant Agreements No. 238875 (GN3) and No. 605243 (GN3plus),
8
 * Horizon 2020 research and innovation programme under Grant Agreements No. 
9
 * 691567 (GN4-1) and No. 731122 (GN4-2).
10
 * On behalf of the aforementioned projects, GEANT Association is the sole owner
11
 * of the copyright in all material which was developed by a member of the GÉANT
12
 * project. GÉANT Vereniging (Association) is registered with the Chamber of 
13
 * Commerce in Amsterdam with registration number 40535155 and operates in the 
14
 * UK as a branch of GÉANT Vereniging.
15
 * 
16
 * Registered office: Hoekenrode 3, 1102BR Amsterdam, The Netherlands. 
17
 * UK branch address: City House, 126-130 Hills Road, Cambridge CB2 1PQ, UK
18
 *
19
 * License: see the web/copyright.inc.php file in the file structure or
20
 *          <base_url>/copyright.php after deploying the software
21
 */
22
23
/**
24
 * This file contains the AbstractProfile class. It contains common methods for
25
 * both RADIUS/EAP profiles and SilverBullet profiles
26
 *
27
 * @author Stefan Winter <[email protected]>
28
 * @author Tomasz Wolniewicz <[email protected]>
29
 *
30
 * @package Developer
31
 *
32
 */
33
34
namespace core;
35
36
use \Exception;
37
38
/**
39
 * This class represents an EAP Profile.
40
 * Profiles can inherit attributes from their IdP, if the IdP has some. Otherwise,
41
 * one can set attribute in the Profile directly. If there is a conflict between
42
 * IdP-wide and Profile-wide attributes, the more specific ones (i.e. Profile) win.
43
 * 
44
 * @author Stefan Winter <[email protected]>
45
 * @author Tomasz Wolniewicz <[email protected]>
46
 *
47
 * @license see LICENSE file in root directory
48
 *
49
 * @package Developer
50
 */
51
class DeploymentClassic extends AbstractDeployment {
52
53
    /**
54
     * Class constructor for existing deployments (use 
55
     * IdP::newDeployment() to actually create one). Retrieves all 
56
     * attributes from the DB and stores them in the priv_ arrays.
57
     * 
58
     * @param IdP $idpObject       optionally, the institution to which this Profile belongs. Saves the construction of the IdP instance. If omitted, an extra query and instantiation is executed to find out.
0 ignored issues
show
Coding Style introduced by
Expected 8 spaces after parameter type; 1 found
Loading history...
59
     * @param string|int $deploymentIdRaw identifier of the deployment in the DB, or 
60
     */
61
    public function __construct($idpObject, $deploymentIdRaw = NULL) {
0 ignored issues
show
Unused Code introduced by
The method parameter $idpObject is never used
Loading history...
Unused Code introduced by
The method parameter $deploymentIdRaw is never used
Loading history...
62
        parent::__construct(); // we now have access to our INST database handle and logging
0 ignored issues
show
Bug introduced by
The call to core\AbstractDeployment::__construct() has too few arguments starting with idpObject. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

62
        parent::/** @scrutinizer ignore-call */ 
63
                __construct(); // we now have access to our INST database handle and logging

This check compares calls to functions or methods with their respective definitions. If the call has less arguments than are defined, it raises an issue.

If a function is defined several times with a different number of parameters, the check may pick up the wrong definition and report false positives. One codebase where this has been known to happen is Wordpress. Please note the @ignore annotation hint above.

Loading history...
63
        $this->type = AbstractDeployment::DEPLOYMENTTYPE_MANAGED;
64
        // we need to extract the SP's relevant information from the eduroam DB
65
        // TODO
0 ignored issues
show
Coding Style introduced by
Comment refers to a TODO task

This check looks TODO comments that have been left in the code.

``TODO``s show that something is left unfinished and should be attended to.

Loading history...
66
        $propertyQuery = "SELECT ... FROM ... WHERE ...";
67
        $queryExec = $this->databaseHandle->exec($propertyQuery);
68
        while ($iterator = mysqli_fetch_object(/** @scrutinizer ignore-type */ $queryExec)) {
69
            $this->status = $iterator->status;
70
        }
71
    }
72
73
    /**
74
     * update the last_changed timestamp for this deployment
75
     * 
76
     * @return void
77
     */
78
    public function updateFreshness() {
79
        // we are always fresh - data comes from eduroam DB
80
    }
81
82
    /**
83
     * gets the last-modified timestamp (useful for caching "dirty" check)
84
     * 
85
     * @return string the date in string form, as returned by SQL
86
     */
87
    public function getFreshness() {
88
        // we are always fresh - data comes from eduroam DB
89
        $execLastChange = $this->databaseHandle->exec("SELECT NOW() as last_change");
90
        // SELECT always returns a resource, never a boolean
91
        if ($freshnessQuery = mysqli_fetch_object(/** @scrutinizer ignore-type */ $execLastChange)) {
92
            return $freshnessQuery->last_change;
93
        }
94
    }
95
96
    /**
97
     * Deletes the deployment from database
98
     * 
99
     * @return void
100
     */
101
    public function destroy() {
102
        // we can't delete data from the eduroam DB
103
    }
104
105
}
106