File tree Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Expand file tree Collapse file tree 2 files changed +49
-0
lines changed Original file line number Diff line number Diff line change 2
2
3
3
namespace Omnipay \Common ;
4
4
5
+ use DateTime ;
6
+ use DateTimeZone ;
5
7
use Omnipay \Common \Exception \InvalidCreditCardException ;
6
8
use Symfony \Component \HttpFoundation \ParameterBag ;
7
9
@@ -631,4 +633,32 @@ public function setEmail($value)
631
633
{
632
634
return $ this ->setParameter ('email ' , $ value );
633
635
}
636
+
637
+ public function getBirthday ($ format = 'Y-m-d ' )
638
+ {
639
+ $ value = $ this ->getParameter ('birthday ' );
640
+
641
+ return $ value ? $ value ->format ($ format ) : null ;
642
+ }
643
+
644
+ public function setBirthday ($ value )
645
+ {
646
+ if ($ value ) {
647
+ $ value = new DateTime ($ value , new DateTimeZone ('UTC ' ));
648
+ } else {
649
+ $ value = null ;
650
+ }
651
+
652
+ return $ this ->setParameter ('birthday ' , $ value );
653
+ }
654
+
655
+ public function getGender ()
656
+ {
657
+ return $ this ->getParameter ('gender ' );
658
+ }
659
+
660
+ public function setGender ($ value )
661
+ {
662
+ return $ this ->setParameter ('gender ' , $ value );
663
+ }
634
664
}
Original file line number Diff line number Diff line change @@ -498,4 +498,23 @@ public function testEmail()
498
498
$ this ->
card ->
setEmail (
'[email protected] ' );
499
499
$ this ->
assertEquals (
'[email protected] ' ,
$ this ->
card ->
getEmail ());
500
500
}
501
+
502
+ public function testBirthday ()
503
+ {
504
+ $ this ->card ->setBirthday ('01-02-2000 ' );
505
+ $ this ->assertEquals ('2000-02-01 ' , $ this ->card ->getBirthday ());
506
+ $ this ->assertEquals ('01/02/2000 ' , $ this ->card ->getBirthday ('d/m/Y ' ));
507
+ }
508
+
509
+ public function testBirthdayEmpty ()
510
+ {
511
+ $ this ->card ->setBirthday ('' );
512
+ $ this ->assertNull ($ this ->card ->getBirthday ());
513
+ }
514
+
515
+ public function testGender ()
516
+ {
517
+ $ this ->card ->setGender ('female ' );
518
+ $ this ->assertEquals ('female ' , $ this ->card ->getGender ());
519
+ }
501
520
}
You can’t perform that action at this time.
0 commit comments