Code Duplication    Length = 15-15 lines in 4 locations

src/WHM/Accounts.php 4 locations

@@ 582-596 (lines=15) @@
579
     * @throws ClientExceptions
580
     * @throws Exception
581
     */
582
    public function setDigestAuth($user, $password, $enableDigestAuth = true)
583
    {
584
        $params = ['user' => $user, 'password' => $password, 'digestauth' => (int) $enableDigestAuth];
585
        $result = $this->client->sendRequest("/json-api/set_digest_auth", "GET", $params);
586
587
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
588
            throw new ClientExceptions($result['metadata']['reason']);
589
        }
590
591
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
592
            return true;
593
        }
594
595
        return false;
596
    }
597
598
    /**
599
     * This function checks whether a cPanel user's home directory contains a valid .my.cnf file.
@@ 898-912 (lines=15) @@
895
     * @throws ClientExceptions
896
     * @throws Exception
897
     */
898
    public function remove($username, $keepDNS = false)
899
    {
900
        $params = ['user' => $username, 'keepdns' => (int) $keepDNS];
901
        $result = $this->client->sendRequest("/json-api/removeacct", "GET", $params);
902
903
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
904
            throw new ClientExceptions($result['metadata']['reason']);
905
        }
906
907
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
908
            return true;
909
        }
910
911
        return false;
912
    }
913
914
    /**
915
     * This function retrieves account bandwidth information.
@@ 989-1003 (lines=15) @@
986
     * @throws ClientExceptions
987
     * @throws Exception
988
     */
989
    public function suspend($user, $reason, $disallowUnsuspension = true)
990
    {
991
        $params = ['user' => $user, 'reason' => $reason, 'disallowun' => (int) $disallowUnsuspension];
992
        $result = $this->client->sendRequest("/json-api/suspendacct", "GET", $params);
993
994
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
995
            throw new ClientExceptions($result['metadata']['reason']);
996
        }
997
998
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
999
            return true;
1000
        }
1001
1002
        return false;
1003
    }
1004
1005
    /**
1006
     * This function unsuspends an account.
@@ 1016-1030 (lines=15) @@
1013
     * @throws ClientExceptions
1014
     * @throws Exception
1015
     */
1016
    public function unsuspend($user)
1017
    {
1018
        $params = ['user' => $user];
1019
        $result = $this->client->sendRequest("/json-api/unsuspendacct", "GET", $params);
1020
1021
        if(!empty($result['metadata']) && $result['metadata']['result'] === 0){
1022
            throw new ClientExceptions($result['metadata']['reason']);
1023
        }
1024
1025
        if(!empty($result['metadata']) && $result['metadata']['result'] === 1){
1026
            return true;
1027
        }
1028
1029
        return false;
1030
    }
1031
1032
    /**
1033
     * This function checks for username conflicts during account creation.