Completed
Pull Request — master (#9)
by Lars
02:45
created

Client::getHandledRegistrations()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 9.4285
c 0
b 0
f 0
cc 1
eloc 3
nc 1
nop 0
crap 2
1
<?php
2
/**
3
 * SDK to communicate with EDBBrugs
4
 *
5
 * PHP Version 5
6
 *
7
 * @category EDBBrugs
8
 * @package  EDBBrugs
9
 * @author   Lars Olesen <[email protected]>
10
 * @license  MIT Open Source License https://opensource.org/licenses/MIT
11
 * @version  GIT: <git_id>
12
 */
13
14
namespace EDBBrugs;
15
16
use EDBBrugs\ClientInterface;
17
18
/**
19
 * Service Communicator with EDB-Brugs
20
 *
21
 * @category EDBBrugs
22
 * @package  EDBBrugs
23
 * @author   Lars Olesen <[email protected]>
24
 * @license  MIT Open Source License https://opensource.org/licenses/MIT
25
 * @version  GIT: <git_id>
26
 */
27
class Client implements ClientInterface
28
{
29
    protected $soap;
30
    protected $credentials;
31
32
    /**
33
     * Constructor
34
     *
35
     * @param object $soap Soap Client
36
     */
37
    public function __construct(CredentialsInterface $credentials, $soap)
38
    {
39
        $this->credentials = $credentials;
40
        $this->soap = $soap;
41
    }
42
43
    /**
44
     * @param array $registrations
45
     *
46
     * @return object RegistrationsCreateResponse
47
     */
48
    public function createNewRegistrations(array $registrations)
49
    {
50
        $xml = new \SimpleXMLElement('<Tilmeldinger/>');
51
        $user = $xml->addChild('User');
52
        $user->addChild('Username', $this->credentials->getUsername());
53
        $user->addChild('Passw', $this->credentials->getPassword());
54
        $user->addChild('Skolekode', $this->credentials->getSchoolCode());
55
        foreach ($registrations as $registration) {
56
            $reg = $xml->addChild('Tilmelding');
57
            foreach ($registration as $key => $value) {
58
                $reg->addChild($key, $value);
59
            }
60
        }
61
62
        $params = array();
63
        $params['XmlData'] = new \SoapVar($xml->asXml(), XSD_STRING);
64
65
        return new RegistrationsCreateResponse($this->soap->NyTilmelding2($params));
66
    }
67
68
    /**
69
     * Gets new registrations
70
     *
71
     * @param string $weblist_id
0 ignored issues
show
Bug introduced by
There is no parameter named $weblist_id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
72
     *
73
     * @return Response
74
     */
75
    public function getNewRegistrations()
76
    {
77
        $params = $this->credentials->getArray();
78
        return new Response($this->soap->HentNyeTilmeldingerV2($params));
79
    }
80
81
    /**
82
     * Gets handled registrations
83
     *
84
     * @param string $weblist_id
0 ignored issues
show
Bug introduced by
There is no parameter named $weblist_id. Was it maybe removed?

This check looks for PHPDoc comments describing methods or function parameters that do not exist on the corresponding method or function.

Consider the following example. The parameter $italy is not defined by the method finale(...).

/**
 * @param array $germany
 * @param array $island
 * @param array $italy
 */
function finale($germany, $island) {
    return "2:1";
}

The most likely cause is that the parameter was removed, but the annotation was not.

Loading history...
85
     *
86
     * @return Response
87
     */
88
    public function getHandledRegistrations()
89
    {
90
        $params = $this->credentials->getArray();
91
        return new Response($this->soap->HentBehandledeTilmeldingerV2($params));
92
    }
93
94
    /**
95
     * Delete registrations
96
     *
97
     * @param string $weblist_id
98
     *
99
     * @return Response
100
     */
101
    public function deleteRegistrations($weblist_id)
0 ignored issues
show
Unused Code introduced by
The parameter $weblist_id is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
102
    {
103
        throw new \Exception('It is not possible to delete registrations using the SOAP webservice');
104
    }
105
}
106