Passed
Branch 3.x (80fbf8)
by Enjoys
01:46
created

CaptchaBase   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 31
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 4
eloc 9
dl 0
loc 31
rs 10
c 1
b 0
f 0

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getName() 0 3 1
A setRuleMessage() 0 3 1
A setName() 0 3 1
A getRuleMessage() 0 3 1
1
<?php
2
3
/*
4
 * The MIT License
5
 *
6
 * Copyright 2020 Enjoys.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
declare(strict_types=1);
28
29
namespace Enjoys\Forms\Captcha;
30
31
/**
32
 *
33
 * @author Enjoys
34
 */
35
abstract class CaptchaBase implements CaptchaInterface
36
{
37
    use \Enjoys\Forms\Traits\Request;
38
    use \Enjoys\Traits\Options;
39
40
    protected string $name;
41
    protected ?string $ruleMessage;
42
43
    public function setName(string $name): void
44
    {
45
        $this->name = $name;
46
    }
47
48
    public function getName(): string
49
    {
50
        return $this->name;
51
    }
52
53
    public function getRuleMessage(): ?string
54
    {
55
        return $this->ruleMessage;
56
    }
57
58
    public function setRuleMessage(?string $message = null): void
59
    {
60
        $this->ruleMessage = $message;
61
    }
62
63
    abstract public function renderHtml(\Enjoys\Forms\Element $element): string;
64
65
    abstract public function validate(\Enjoys\Forms\Element $element): bool;
66
}
67