HaveIBeenPwnedPage   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
eloc 6
dl 0
loc 27
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getControllerName() 0 3 1
A canCreate() 0 8 2
1
<?php
2
3
namespace Firesphere\HaveIBeenPwned\Models;
4
5
use Firesphere\HaveIBeenPwned\Controllers\HaveIBeenPwnedPageController;
6
use Page;
7
use SilverStripe\Security\Member;
8
9
// This page should not be instantiated if the Page class doesn't exist.
10
if (!class_exists('\Page')) {
11
    return;
12
}
13
14
/**
15
 * Class \Firesphere\HaveIBeenPwned\Models\HaveIBeenPwnedPage
16
 *
17
 */
18
class HaveIBeenPwnedPage extends Page
19
{
20
    private static $table_name = 'HaveIBeenPwnedPage';
0 ignored issues
show
introduced by
The private property $table_name is not used, and could be removed.
Loading history...
21
22
    /**
23
     * Get the controller name for this page
24
     *
25
     * @return string
26
     */
27
    public function getControllerName()
28
    {
29
        return HaveIBeenPwnedPageController::class;
30
    }
31
32
    /**
33
     * @param null|Member $member
34
     * @param array $context
35
     * @return bool
36
     */
37
    public function canCreate($member = null, $context = array())
38
    {
39
        // This page should only exist once
40
        if (static::get()->count()) {
41
            return false;
42
        }
43
44
        return parent::canCreate($member, $context);
45
    }
46
}
47