Code Duplication    Length = 3-6 lines in 8 locations

src/WHM/Accounts.php 7 locations

@@ 359-361 (lines=3) @@
356
357
        $result = $this->client->sendRequest("/json-api/createacct", "GET", $params);
358
359
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
360
            throw new ClientExceptions($result['metadata']['reason']);
361
        }
362
363
        if ( ! empty($result) && ! empty($result['result'][0]) && $result['result'][0]['status'] === 0) {
364
            throw new ClientExceptions($result['result'][0]['statusmsg']);
@@ 480-482 (lines=3) @@
477
        $params['users_json'] = json_encode($usersJson);
478
479
        $result = $this->client->sendRequest("/json-api/forcepasswordchange", "GET", $params);
480
        if ($result['metadata']['result'] === 0) {
481
            throw new ClientExceptions($result['metadata']['reason']);
482
        }
483
484
        if ( ! empty($result['data'])) {
485
            return $result['updated'];
@@ 603-605 (lines=3) @@
600
    {
601
        $params = ['user' => $user, 'bwlimit' => intval($bwlimit)];
602
        $result = $this->client->sendRequest("/json-api/limitbw", "GET", $params);
603
        if ( ! empty($result['metadata']) && $result['metadata']['result'] === 1) {
604
            return $result['data']['bwlimits'][0];
605
        }
606
607
        return null;
608
    }
@@ 805-807 (lines=3) @@
802
            return true;
803
        }
804
805
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
806
            throw new ClientExceptions($result['metadata']['reason']);
807
        }
808
809
        return false;
810
    }
@@ 842-844 (lines=3) @@
839
840
        $result = $this->client->sendRequest("/json-api/passwd", "GET", $params);
841
842
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
843
            throw new ClientExceptions($result['metadata']['reason']);
844
        }
845
846
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
847
            return $result['data']['app'];
@@ 846-848 (lines=3) @@
843
            throw new ClientExceptions($result['metadata']['reason']);
844
        }
845
846
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
847
            return $result['data']['app'];
848
        }
849
850
        return null;
851
    }
@@ 870-872 (lines=3) @@
867
        $params = ['user' => $username, 'keepdns' => (int) $keepDNS];
868
        $result = $this->client->sendRequest("/json-api/removeacct", "GET", $params);
869
870
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
871
            throw new ClientExceptions($result['metadata']['reason']);
872
        }
873
874
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
875
            return true;

src/WHMClient.php 1 location

@@ 117-122 (lines=6) @@
114
        }
115
116
        if ($response->getStatusCode() === 403) {
117
            if (!empty($data['cpanelresult']['error'])) {
118
                throw ClientExceptions::accessDenied(
119
                    $data['cpanelresult']['error'],
120
                    $data['cpanelresult']['data']['reason']
121
                );
122
            }
123
        }
124
125
        return $data;