Issues (4)

src/Ridvanbaluyos/Pwned/PasteAccount.php (1 issue)

1
<?php
2
3
namespace Ridvanbaluyos\Pwned;
4
5
use \Ridvanbaluyos\Pwned\Pwned as Pwned;
6
/**
7
 * Getting all data classes in the system
8
 * https://haveibeenpwned.com/API/v2#PastesForAccount
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 PasteAccount extends Pwned
0 ignored issues
show
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...
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
}