Test Failed
Push — master ( 634833...ea7adf )
by Vítězslav
03:19
created

Kontakt   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 30
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

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

1 Method

Rating   Name   Duplication   Size   Complexity  
A authenticate() 0 12 2
1
<?php
2
/**
3
 * FlexiPeeHP - Objekt kontaktu.
4
 *
5
 * @author     Vítězslav Dvořák <[email protected]>
6
 * @copyright  (C) 2015-2017 Spoje.Net
7
 */
8
9
namespace FlexiPeeHP;
10
11
/**
12
 * Kontakt adresáře
13
 *
14
 * @link https://demo.flexibee.eu/c/demo/kontakt/properties
15
 */
16
class Kontakt extends FlexiBeeRW
17
{
18
    /**
19
     * Evidence užitá objektem.
20
     *
21
     * @var string
22
     */
23
    public $evidence = 'kontakt';
24
25
    /**
26
     * Authenticate by contact
27
     *
28
     * @link https://www.flexibee.eu/api/dokumentace/ref/autentizace-kontaktu/ Contact Auth
29
     * @param string $login
30
     * @param string $password
31
     * @return boolean
32
     */
33
    public function authenticate($login, $password)
34
    {
35
        $defaultHttpHeaders                       = $this->defaultHttpHeaders;
36
        $this->defaultHttpHeaders['Content-Type'] = 'application/x-www-form-urlencoded';
37
        $this->setPostFields(http_build_query(['username' => $login, 'password' => $password]));
38
        $result                                   = $this->performRequest($this->evidence.'/authenticate',
39
            'POST', 'xml');
40
        $this->defaultHttpHeaders                 = $defaultHttpHeaders;
41
        $this->addStatusMessage($result['message'],
42
            $result['success'] == 'true' ? 'success' : 'warning' );
43
        return $result['success'] == 'true';
44
    }
45
}
46