Overview

Namespaces

  • SMSApi
    • Api
      • Action
        • Phonebook
        • Sender
        • Sms
        • User
      • Response
    • Exception
    • Proxy
      • Http

Classes

  • SMSApi\Proxy\Http\AbstractHttp
  • SMSApi\Proxy\Http\Curl
  • SMSApi\Proxy\Http\Native
  • Overview
  • Namespace
  • Class
 1: <?php
 2: 
 3: namespace SMSApi;
 4: 
 5: use SMSApi\Exception\ClientException;
 6: 
 7: /**
 8:  * Class Client
 9:  * @package SMSApi
10:  */
11: class Client {
12: 
13:     /**
14:      * @var string
15:      */
16:     private $username;
17: 
18:     /**
19:      * @var string
20:      */
21:     private $password;
22: 
23:     /**
24:      * @param $username
25:      */
26:     public function __construct( $username ) {
27:         $this->setUsername( $username );
28:     }
29: 
30:     /**
31:      * Set the username used to authenticate the user.
32: 
33:      * @param $username string
34:      * @return $this
35:      * @throws Exception\ClientException
36:      */
37:     public function setUsername( $username ) {
38: 
39:         if ( empty( $username ) ) {
40:             throw new ClientException( "Username can not be empty" );
41:         }
42: 
43:         $this->username = $username;
44:         return $this;
45:     }
46: 
47:     /**
48:      * Set password encoded with md5 algorithm.
49:      *
50:      * @param $password
51:      * @return $this
52:      * @throws Exception\ClientException
53:      */
54:     public function setPasswordHash( $password ) {
55: 
56:         if ( empty( $password ) ) {
57:             throw new ClientException( "Password can not be empty" );
58:         }
59: 
60:         $this->password = $password;
61:         return $this;
62:     }
63: 
64:     /**
65:      * Set password in plain text.
66:      *
67:      * @param $password
68:      * @return $this
69:      * @throws Exception\ClientException
70:      */
71:     public function setPasswordRaw( $password ) {
72:         $this->setPasswordHash( md5( $password ) );
73:         return $this;
74:     }
75: 
76:     /**
77:      * Returns the username used to authenticate the user.
78:      *
79:      * @return string The username
80:      */
81:     public function getUsername() {
82:         return $this->username;
83:     }
84: 
85:     /**
86:      * Returns password
87:      *
88:      * @return string The salt password
89:      */
90:     public function getPassword() {
91:         return $this->password;
92:     }
93: 
94: }
95: 
SMSAPI Api Client API documentation generated by ApiGen