Code Duplication    Length = 38-40 lines in 2 locations

src/Ridvanbaluyos/Pwned/Breach.php 1 location

@@ 15-52 (lines=38) @@
12
 * @link       https://github.com/ridvanbaluyos/haveibeenpwned
13
 * @license    MIT
14
 */
15
class Breach extends Pwned
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;
50
        return $this;
51
    }
52
}

src/Ridvanbaluyos/Pwned/PasteAccount.php 1 location

@@ 15-54 (lines=40) @@
12
 * @link       https://github.com/ridvanbaluyos/haveibeenpwned
13
 * @license    MIT
14
 */
15
class PasteAccount extends Pwned
16
{
17
    private $account;
18
19
    /**
20
     * PasteAccount constructor.
21
     */
22
    public function __construct()
23
    {
24
        parent::__construct();
25
    }
26
27
    /**
28
     * This function gets all pastes for an account
29
     *
30
     * @return array
31
     */
32
    public function get(): array
33
    {
34
        // No account has been set, return empty array.
35
        if (!isset($this->account)) return [];
36
37
        $url = $this->endpoint . 'pasteaccount/' . $this->account;
38
        $pasteAccounts = $this->requestGet($url);
39
40
        return $pasteAccounts;
41
    }
42
43
    /**
44
     * Sets the account.
45
     *
46
     * @param string $account
47
     * @return $this
48
     */
49
    public function setAccount(string $account)
50
    {
51
        $this->account = $account;
52
        return $this;
53
    }
54
}