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.

CaptchaModel::checkCaptcha()   A
last analyzed

Complexity

Conditions 3
Paths 2

Size

Total Lines 8

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
dl 0
loc 8
rs 10
c 0
b 0
f 0
cc 3
nc 2
nop 1
1
<?php
2
3
/**
4
 * Class CaptchaModel
5
 *
6
 * This model class handles all the captcha stuff.
7
 * Currently this uses the excellent Captcha generator lib from https://github.com/Gregwar/Captcha
8
 * Have a look there for more options etc.
9
 */
10
class CaptchaModel
11
{
12
    /**
13
     * Generates the captcha, "returns" a real image, this is why there is header('Content-type: image/jpeg')
14
     * Note: This is a very special method, as this is echoes out binary data.
15
     */
16
    public static function generateAndShowCaptcha()
17
    {
18
        // create a captcha with the CaptchaBuilder lib (loaded via Composer)
19
        $captcha = new Gregwar\Captcha\CaptchaBuilder;
20
        $captcha->build(
21
            Config::get('CAPTCHA_WIDTH'),
22
            Config::get('CAPTCHA_HEIGHT')
23
        );
24
25
        // write the captcha character into session
26
        Session::set('captcha', $captcha->getPhrase());
27
28
        // render an image showing the characters (=the captcha)
29
        header('Content-type: image/jpeg');
30
        $captcha->output();
31
    }
32
33
    /**
34
     * Checks if the entered captcha is the same like the one from the rendered image which has been saved in session
35
     * @param $captcha string The captcha characters
36
     * @return bool success of captcha check
37
     */
38
    public static function checkCaptcha($captcha)
39
    {
40
        if (Session::get('captcha') && ($captcha == Session::get('captcha'))) {
41
            return true;
42
        }
43
44
        return false;
45
    }
46
}
47