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

PublicRequestRouter   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 49
Duplicated Lines 0 %

Test Coverage

Coverage 0%

Importance

Changes 0
Metric Value
wmc 5
eloc 19
c 0
b 0
f 0
dl 0
loc 49
ccs 0
cts 31
cp 0
rs 10

3 Methods

Rating   Name   Duplication   Size   Complexity  
A getDefaultRoute() 0 3 1
A getRouteMap() 0 20 1
A getRouteFromPath() 0 8 3
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
}