1 | <?php |
||
2 | |||
3 | namespace Ridvanbaluyos\Pwned; |
||
4 | |||
5 | use \Ridvanbaluyos\Pwned\Pwned as Pwned; |
||
6 | /** |
||
7 | * Getting a single breached site |
||
8 | * https://haveibeenpwned.com/API/v2#SingleBreach |
||
9 | * |
||
10 | * @package Pwned |
||
11 | * @author Ridvan Baluyos <[email protected]> |
||
12 | * @link https://github.com/ridvanbaluyos/haveibeenpwned |
||
13 | * @license MIT |
||
14 | */ |
||
15 | View Code Duplication | class Breach extends Pwned |
|
0 ignored issues
–
show
|
|||
16 | { |
||
17 | /** |
||
18 | * Breaches constructor. |
||
19 | */ |
||
20 | public function __construct() |
||
21 | { |
||
22 | parent::__construct(); |
||
23 | } |
||
24 | |||
25 | /** |
||
26 | * This function gets a specific breach. |
||
27 | * |
||
28 | * @return array |
||
29 | */ |
||
30 | public function get(): array |
||
31 | { |
||
32 | // No domain has been set, return empty array. |
||
33 | if (!isset($this->domain)) return []; |
||
34 | |||
35 | $url = $this->endpoint . 'breach/' . $this->domain; |
||
36 | $breaches = $this->requestGet($url); |
||
37 | |||
38 | return $breaches; |
||
39 | } |
||
40 | |||
41 | /** |
||
42 | * Sets the domain filter. Filter the results only to the domain specified. |
||
43 | * |
||
44 | * @param string $domain |
||
45 | * @return $this |
||
46 | */ |
||
47 | public function setDomain(string $domain) |
||
48 | { |
||
49 | $this->domain = $domain; |
||
0 ignored issues
–
show
|
|||
50 | return $this; |
||
51 | } |
||
52 | } |
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.