GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.

DataUtilityServiceProvider   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 58
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 0
Metric Value
wmc 6
lcom 0
cbo 1
dl 0
loc 58
rs 10
c 0
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A checkPasswordPolicy() 0 10 3
A getMailFromOu() 0 8 1
A register() 0 9 1
A boot() 0 4 1
1
<?php
2
namespace SOG\Dashboard;
3
4
5
use Silex\Application;
6
use Silex\ServiceProviderInterface;
7
8
/**
9
 * Provides simple static methods which work on strings.
10
 *
11
 * Class DataUtilityServiceProvider
12
 * @package SOG\Dashboard
13
 */
14
class DataUtilityServiceProvider implements ServiceProviderInterface
15
{
16
17
    /**
18
     * Check if the given password complies with our password policy.
19
     *
20
     * @param string $password
21
     * @param int $minLength The minimum length for the password
22
     * @param string $regex The regex for checking the password character classes
23
     * @return bool True if the given password complies with the password policy, false otherwise.
24
     */
25
    private static function checkPasswordPolicy($password, $minLength = 8, $regex = '/^.*([0-9]+.*[^0-9a-zA-Z]+|[^0-9a-zA-Z]+.*[0-9]+)+.*$/')
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
26
    {
27
        if (strlen($password) < $minLength) {
28
            return false;
29
        }
30
        if (preg_match($regex, $password) === 0) {
31
            return false;
32
        }
33
        return true;
34
    }
35
36
    /**
37
     * Replaces certain prefixes of an OU to retrieve the mailbox name.
38
     *
39
     * @param string $ou
40
     * @return string The modified string
41
     */
42
    private static function getMailFromOu($ou)
0 ignored issues
show
Unused Code introduced by
This method is not used, and could be removed.
Loading history...
43
    {
44
        $ou = strtolower($ou);
45
        $prefixes = [
46
            'ak_', 'lg_', 'ressort_'
47
        ];
48
        return str_replace($prefixes, '', $ou);
49
    }
50
51
    /**
52
     * {@inheritdoc}
53
     */
54
    public function register(Application $app)
55
    {
56
        $app['check_password_policy'] = $app->protect(function () {
57
            return call_user_func_array('self::checkPasswordPolicy', func_get_args());
58
        });
59
        $app['get_mail_from_ou'] = $app->protect(function () {
60
            return call_user_func_array('self::getMailFromOu', func_get_args());
61
        });
62
    }
63
64
    /**
65
     * {@inheritdoc}
66
     */
67
    public function boot(Application $app)
68
    {
69
        // nothing to do here
70
    }
71
}
72