CodeHelper   A
last analyzed

Complexity

Total Complexity 1

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 8
dl 0
loc 23
rs 10
c 0
b 0
f 0
wmc 1

1 Method

Rating   Name   Duplication   Size   Complexity  
A getCodesFromSession() 0 16 1
1
<?php
2
3
namespace Firesphere\BootstrapMFA\Tests\Helpers;
4
5
use SilverStripe\Control\Controller;
6
use SilverStripe\Control\Session;
7
8
class CodeHelper
9
{
10
    /**
11
     * Get the codes from the session for testing reasons
12
     *
13
     * @return array
14
     */
15
    public static function getCodesFromSession()
16
    {
17
        // Funky stuff, extract the codes from the session message
18
        /** @var Session $session */
19
        $session = Controller::curr()->getRequest()->getSession();
20
21
        $message = $session->get('tokens');
22
23
        $message = str_replace('<p>Here are your tokens, please store them securily. ' .
24
            'They are stored encrypted and can not be recovered, only reset.</p><p>', '', $message);
25
        $codes = explode('<br />', $message);
26
27
        // Remove the <p> at the end
28
        array_pop($codes);
29
30
        return $codes;
31
    }
32
}
33