@@ -7,7 +7,7 @@ class Card implements Paymethod
77    private  $ year
88    private  $ month
99
10-     public  function  __construct ($ card_number$ year$ month
10+     public  function  __construct (string   $ card_numberint   $ year  int  $ month
1111    {
1212        $ this set_card_number ($ card_number
1313        $ this set_expiration_date ($ year$ month
@@ -18,12 +18,8 @@ public function get_card_number()
1818        return  $ this card_number ;
1919    }
2020
21-     public  function  set_card_number ($ card_number
21+     public  function  set_card_number (string   $ card_number
2222    {
23-         if  (gettype ($ card_number"string " ) {
24-             throw  new  \Exception ('$card_number must be a string. ' );
25-         }
26- 
2723        if (!preg_match ("/^[0-9]{14,19}$/ " , $ card_number
2824            throw  new  \Exception ('$card_number don \'t match with pattern. ' );
2925        }
@@ -41,22 +37,14 @@ public function get_month()
4137        return  $ this month ;
4238    }
4339
44-     public  function  set_expiration_date ($ year$ month
40+     public  function  set_expiration_date (int   $ year  int  $ month
4541    {
46-         if  (gettype ($ year"integer " ) {
47-             throw  new  \Exception ('$year must be a string. ' );
48-         }
49- 
5042        if ($ year1000  or  $ year9999 ) {
5143            throw  new  \Exception ('$year doesn \'t have a correct value. ' );
5244        }
5345
5446        $ this year  = $ year
5547
56-         if  (gettype ($ month"integer " ) {
57-             throw  new  \Exception ('$month must be a string. ' );
58-         }
59- 
6048        if ($ month1  or  $ month12 ) {
6149            throw  new  \Exception ('$month doesn \'t have a correct value. ' );
6250        }
0 commit comments