Completed
Push — master ( e17d9a...f8eac8 )
by Austin
01:42
created

Acknowledgement   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 36
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 36
loc 36
rs 10
c 0
b 0
f 0
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A setAcknowledgement() 9 9 2
A getAcknowledgement() 3 3 1

How to fix   Duplicated Code   

Duplicated Code

Duplicate code is one of the most pungent code smells. A rule that is often used is to re-structure code once it is duplicated in three or more places.

Common duplication problems, and corresponding solutions are:

1
<?php
2
/**
3
 * src/Directives/Acknowledgement.php
4
 *
5
 * @package     php-security-txt
6
 * @author      Austin Heap <[email protected]>
7
 * @version     v0.4.0
8
 */
9
10
declare(strict_types = 1);
11
12
namespace AustinHeap\Security\Txt\Directives;
13
14
use AustinHeap\Security\Txt\SecurityTxt;
15
use Exception;
16
17
/**
18
 * Acknowledgement
19
 *
20
 * @link        https://github.com/austinheap/php-security-txt
21
 * @link        https://packagist.org/packages/austinheap/php-security-txt
22
 * @link        https://austinheap.github.io/php-security-txt/classes/AustinHeap.Security.Txt.SecurityTxt.html
23
 */
24 View Code Duplication
trait Acknowledgement
0 ignored issues
show
Duplication introduced by
This class seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
25
{
26
27
    /**
28
     * The acknowledgement URL.
29
     *
30
     * @var string
31
     */
32
    protected $acknowledgement = null;
33
34
    /**
35
     * Set the acknowledgement URL.
36
     *
37
     * @param  string $acknowledgement
38
     *
39
     * @return SecurityTxt
40
     */
41
    public function setAcknowledgement(string $acknowledgement): SecurityTxt
42
    {
43
        if (filter_var($acknowledgement, FILTER_VALIDATE_URL) === false) {
44
            throw new Exception('Acknowledgement must be a well-formed URL.');
45
        }
46
47
        $this->acknowledgement = $acknowledgement;
48
49
        return $this;
0 ignored issues
show
Bug Best Practice introduced by
The expression return $this returns the type AustinHeap\Security\Txt\Directives\Acknowledgement which includes types incompatible with the type-hinted return AustinHeap\Security\Txt\SecurityTxt.
Loading history...
50
    }
51
52
    /**
53
     * Get the acknowledgement URL.
54
     *
55
     * @return string
56
     */
57
    public function getAcknowledgement(): string
58
    {
59
        return $this->acknowledgement;
60
    }
61
62
}
63