Passed
Push — 2.x ( 364dd8...03335a )
by Terry
01:58
created

DemoModeTrait::demo()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 6
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 3
c 0
b 0
f 0
nc 1
nop 2
dl 0
loc 6
rs 10
1
<?php
2
/*
3
 * This file is part of the Shieldon package.
4
 *
5
 * (c) Terry L. <[email protected]>
6
 *
7
 * For the full copyright and license information, please view the LICENSE
8
 * file that was distributed with this source code.
9
 */
10
11
declare(strict_types=1);
12
13
namespace Shieldon\Firewall\Panel;
14
15
/*
16
 * Tradit for demonstration.
17
 */
18
trait DemoModeTrait
19
{
20
    /**
21
     * self: Shieldon | managed: Firewall | demo: Demo
22
     *
23
     * @var string
24
     */
25
    protected $mode = 'self';
26
27
    /**
28
     * Login as a demo user.
29
     *
30
     * @var array
31
     */
32
    protected $demoUser = [
33
        'user' => 'demo',
34
        'pass' => 'demo',
35
    ];
36
37
    /**
38
     * In demo mode, user's submit will not take effect.
39
     *
40
     * @param string $user The user name.
41
     * @param string $pass The user password.
42
     *
43
     * @return void
44
     */
45
    public function demo(string $user = '', string $pass = ''): void
46
    {
47
        $this->demoUser['user'] = $user ?? 'demo';
48
        $this->demoUser['pass'] = $pass ?? 'demo';
49
50
        $this->mode = 'demo';
51
    }
52
}
53