Passed
Push — multiproject/requestforms ( 675fe5 )
by Simon
08:58 queued 04:51
created

PublicRequestRouter::getRouteFromPath()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 8
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 12

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 8
ccs 0
cts 7
cp 0
rs 10
cc 3
nc 2
nop 1
crap 12
1
<?php
2
/******************************************************************************
3
 * Wikipedia Account Creation Assistance tool                                 *
4
 *                                                                            *
5
 * All code in this file is released into the public domain by the ACC        *
6
 * Development Team. Please see team.json for a list of contributors.         *
7
 ******************************************************************************/
8
9
namespace Waca\Router;
10
11
use Waca\Pages\Request\PageConfirmEmail;
12
use Waca\Pages\Request\PageEmailConfirmationRequired;
13
use Waca\Pages\Request\PageRequestAccount;
14
use Waca\Pages\Request\PageRequestSubmitted;
15
16
class PublicRequestRouter extends RequestRouter
17
{
18
    /**
19
     * Gets the route map to be used by this request router.
20
     *
21
     * @return array
22
     */
23
    protected function getRouteMap()
24
    {
25
        return array(
26
            // Page showing a message stating the request has been submitted to our internal queues
27
            'requestSubmitted'          =>
28
                array(
29
                    'class'   => PageRequestSubmitted::class,
30
                    'actions' => array(),
31
                ),
32
            // Page showing a message stating that email confirmation is required to continue
33
            'emailConfirmationRequired' =>
34
                array(
35
                    'class'   => PageEmailConfirmationRequired::class,
36
                    'actions' => array(),
37
                ),
38
            // Action page which handles email confirmation
39
            'confirmEmail'              =>
40
                array(
41
                    'class'   => PageConfirmEmail::class,
42
                    'actions' => array(),
43
                ),
44
        );
45
    }
46
47
    /**
48
     * Gets the default route if no explicit route is requested.
49
     *
50
     * @return callable
51
     */
52
    protected function getDefaultRoute()
53
    {
54
        return array(PageRequestAccount::class, 'main');
55
    }
56
57
    public function getRouteFromPath($pathInfo): array
58
    {
59
        if (count($pathInfo) === 3 && $pathInfo[0] === 'r') {
60
            // this request should be routed to the dynamic request form handler
61
            return [PageRequestAccount::class, 'dynamic'];
62
        }
63
        else {
64
            return parent::getRouteFromPath($pathInfo);
65
        }
66
    }
67
}