Completed
Push — master ( 6da2a1...0ace3e )
by Tim
01:25
created

Bind::invokeTest()   A

Complexity

Conditions 2
Paths 2

Size

Total Lines 17
Code Lines 12

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 2
eloc 12
nc 2
nop 0
dl 0
loc 17
rs 9.4285
c 0
b 0
f 0
1
<?php
2
3
namespace SimpleSAML\Module\monitor\TestCase\AuthSource\Ldap;
4
5
use \SimpleSAML\Module\monitor\State as State;
6
7
final class Bind extends \SimpleSAML\Module\monitor\TestCase
0 ignored issues
show
Coding Style introduced by
Bind does not seem to conform to the naming convention (^sspmod_monitor_([A-Z][a-zA-Z0-9_]+)+$).

This check examines a number of code elements and verifies that they conform to the given naming conventions.

You can set conventions for local variables, abstract classes, utility classes, constant, properties, methods, parameters, interfaces, classes, exceptions and special methods.

Loading history...
8
{
9
    private $connection = null;
10
    private $username = null;
11
    private $password = null;
12
13
    /*
14
     * @return void
15
     */
16
    protected function initialize()
17
    {
18
        $authsourceData = $this->getInput('authsource_data');
19
20
        $this->connection = $this->getInput('connection');
21
        $this->username = $authsourceData['search.username'];
22
        $this->password = $authsourceData['search.password'];
23
        $this->setSubject($this->username);
24
    }
25
26
    /*
27
     * @return void
28
     */
29
    protected function invokeTest()
30
    {
31
        $connection = $this->connection;
32
        $subject = $this->getSubject();
33
34
        try {
35
            $connection->bind($this->username, $this->password);
36
        } catch (Exception $e) {
0 ignored issues
show
Bug introduced by
The class SimpleSAML\Module\monito...thSource\Ldap\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
37
            $msg = str_replace('Library - LDAP bind(): ', '', $e->getMessage());
38
            $this->setState(State::ERROR);
39
            $this->addMessage(State::ERROR, 'LDAP Bind', $subject, $msg);
40
            return;
41
        }
42
43
        $this->setState(State::OK);
44
        $this->addMessage(State::OK, 'LDAP Bind', $subject, 'Bind succesful');
45
    }
46
}
47