File tree Expand file tree Collapse file tree 4 files changed +41
-3
lines changed
src/MessageBird/Resources Expand file tree Collapse file tree 4 files changed +41
-3
lines changed Original file line number Diff line number Diff line change 1010
1111 $ Lookup = $ MessageBird ->lookup ->read ("624971134 " , "NL " );
1212 var_dump ($ Lookup );
13-
1413} catch (\MessageBird \Exceptions \AuthenticateException $ e ) {
1514 // That means that your accessKey is unknown
1615 echo 'wrong login ' ;
Original file line number Diff line number Diff line change 44
55use MessageBird \Objects ;
66use MessageBird \Common ;
7+ use InvalidArgumentException ;
78
89/**
910 * Class Verify
@@ -33,8 +34,11 @@ public function __construct(Common\HttpClient $HttpClient)
3334 * @throws \MessageBird\Exceptions\RequestException
3435 * @throws \MessageBird\Exceptions\ServerException
3536 */
36- public function read ($ phoneNumber = null , $ countryCode = null )
37+ public function read ($ phoneNumber , $ countryCode = null )
3738 {
39+ if (empty ($ phoneNumber )) {
40+ throw new InvalidArgumentException ('The phone number cannot be empty. ' );
41+ }
3842 $ query = null ;
3943 if ($ countryCode != null ) {
4044 $ query = array ("countryCode " => $ countryCode );
Original file line number Diff line number Diff line change 44
55use MessageBird \Objects ;
66use MessageBird \Common ;
7+ use InvalidArgumentException ;
78
89/**
910 * Class LookupHLR
@@ -35,6 +36,10 @@ public function __construct(Common\HttpClient $HttpClient)
3536 */
3637 public function create ($ hlr , $ countryCode = null )
3738 {
39+ if (empty ($ hlr ->msisdn )) {
40+ throw new InvalidArgumentException ('The phone number ($hlr->msisdn) cannot be empty. ' );
41+ }
42+
3843 $ query = null ;
3944 if ($ countryCode != null ) {
4045 $ query = array ("countryCode " => $ countryCode );
@@ -53,8 +58,12 @@ public function create($hlr, $countryCode = null)
5358 * @throws \MessageBird\Exceptions\RequestException
5459 * @throws \MessageBird\Exceptions\ServerException
5560 */
56- public function read ($ phoneNumber = null , $ countryCode = null )
61+ public function read ($ phoneNumber , $ countryCode = null )
5762 {
63+ if (empty ($ phoneNumber )) {
64+ throw new InvalidArgumentException ('The phone number cannot be empty. ' );
65+ }
66+
5867 $ query = null ;
5968 if ($ countryCode != null ) {
6069 $ query = array ("countryCode " => $ countryCode );
Original file line number Diff line number Diff line change @@ -16,6 +16,14 @@ public function testReadLookup()
1616 $ this ->client ->lookup ->read (31612345678 );
1717 }
1818
19+ /**
20+ * @expectedException InvalidArgumentException
21+ */
22+ public function testReadLookupWithEmptyNumber ()
23+ {
24+ $ this ->client ->lookup ->read (null );
25+ }
26+
1927 /**
2028 * @expectedException MessageBird\Exceptions\ServerException
2129 */
@@ -40,6 +48,16 @@ public function testCreateLookupHLR()
4048 $ this ->client ->lookupHLR ->create ($ Hlr );
4149 }
4250
51+ /**
52+ * @expectedException InvalidArgumentException
53+ */
54+ public function testCreateLookupHLRWithEmptyNumber ()
55+ {
56+ $ Hlr = new \MessageBird \Objects \Hlr ();
57+ $ Hlr ->msisdn = null ;
58+ $ this ->client ->lookupHLR ->create ($ Hlr );
59+ }
60+
4361 /**
4462 * @expectedException MessageBird\Exceptions\ServerException
4563 */
@@ -65,6 +83,14 @@ public function testReadLookupHLR()
6583 $ this ->client ->lookupHLR ->read (31612345678 );
6684 }
6785
86+ /**
87+ * @expectedException InvalidArgumentException
88+ */
89+ public function testReadLookupHLRWithEmptyNumber ()
90+ {
91+ $ this ->client ->lookupHLR ->read (null );
92+ }
93+
6894 /**
6995 * @expectedException MessageBird\Exceptions\ServerException
7096 */
You can’t perform that action at this time.
0 commit comments