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

Client::getNewRegistrations()   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
    public function createNewRegistrations(array $registrations)
47
    {
48
        $xml = new \SimpleXMLElement('<Tilmeldinger/>');
49
        $user = $xml->addChild('User');
50
        $user->addChild('Username', $this->credentials->getUsername());
51
        $user->addChild('Passw', $this->credentials->getPassword());
52
        $user->addChild('Skolekode', $this->credentials->getSchoolCode());
53
        foreach ($registrations as $registration) {
54
            $reg = $xml->addChild('Tilmelding');
55
            foreach ($registration as $key => $value) {
56
                $reg->addChild($key, $value);
57
            }
58
        }
59
60
        $params = array();
61
        $params['XmlData'] = new \SoapVar($xml->asXml(), XSD_STRING);
62
63
        return new NewRegistrationsResponse($this->soap->NyTilmelding2($params));
64
    }
65
66
    public function getNewRegistrations()
67
    {
68
        $params = $this->credentials->getArray();
69
        return new Response('HentNyeTilmeldingerV2', $this->soap->HentNyeTilmeldingerV2($params));
0 ignored issues
show
Documentation introduced by
'HentNyeTilmeldingerV2' is of type string, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
70
    }
71
72
    public function getHandledRegistrations()
73
    {
74
        $params = $this->credentials->getArray();
75
        return new Response('HentBehandledeTilmeldingerV2', $this->soap->HentBehandledeTilmeldingerV2($params));
0 ignored issues
show
Documentation introduced by
'HentBehandledeTilmeldingerV2' is of type string, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
76
    }
77
78
    /**
79
     * @param string $weblist_id
80
     */
81
    public function deleteRegistrations($weblist_id)
82
    {
83
        $params = $this->credentials->getArray();
84
        $params['Id_WebListe'] = '72200' . '_' . 'T3';
85
        return new Response('SletTilmeldingerV2', $this->soap->SletTilmeldingerV2($params));
0 ignored issues
show
Documentation introduced by
'SletTilmeldingerV2' is of type string, but the function expects a object.

It seems like the type of the argument is not accepted by the function/method which you are calling.

In some cases, in particular if PHP’s automatic type-juggling kicks in this might be fine. In other cases, however this might be a bug.

We suggest to add an explicit type cast like in the following example:

function acceptsInteger($int) { }

$x = '123'; // string "123"

// Instead of
acceptsInteger($x);

// we recommend to use
acceptsInteger((integer) $x);
Loading history...
86
    }
87
}
88