PasteAccount   A
last analyzed

Complexity

Total Complexity 4

Size/Duplication

Total Lines 38
Duplicated Lines 100 %

Importance

Changes 0
Metric Value
dl 38
loc 38
rs 10
c 0
b 0
f 0
wmc 4

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 3 3 1
A get() 9 9 2
A setAccount() 4 4 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
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
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...
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
}