9
9
10
10
use Magento \Customer \Model \Customer ;
11
11
use Magento \Framework \Validator \AbstractValidator ;
12
+ use Magento \Store \Api \Data \StoreInterface as StoreInterface ;
12
13
use Magento \Store \Model \StoreManagerInterface ;
13
14
14
15
/**
@@ -41,7 +42,7 @@ public function __construct(StoreManagerInterface $storeManager)
41
42
* @param Customer $customer
42
43
* @return bool
43
44
*/
44
- public function isValid ($ customer )
45
+ public function isValid ($ customer ): bool
45
46
{
46
47
if (!$ this ->isValidDob ($ customer ->getDob (), $ customer ->getStoreId ())) {
47
48
parent ::_addMessages ([['dob ' => 'The Date of Birth should not be greater than today. ' ]]);
@@ -54,13 +55,11 @@ public function isValid($customer)
54
55
* Check if specified dob is not in the future
55
56
*
56
57
* @param string|null $dobValue
57
- * @param int $storeId
58
+ * @param null|string|bool| int|StoreInterface $storeId
58
59
* @return bool
59
60
*/
60
- private function isValidDob (?string $ dobValue , int $ storeId ): bool
61
+ private function isValidDob (?string $ dobValue , null | string | bool | int | StoreInterface $ storeId ): bool
61
62
{
62
- if ($ dobValue != null ) {
63
-
64
63
// Get the timezone of the store
65
64
$ store = $ this ->storeManager ->getStore ($ storeId );
66
65
$ timezone = $ store ->getConfig ('general/locale/timezone ' );
@@ -77,7 +76,6 @@ private function isValidDob(?string $dobValue, int $storeId): bool
77
76
if ($ dobTimestamp > $ currentTimestamp ) {
78
77
return false ;
79
78
}
80
- }
81
79
82
80
return true ;
83
81
}
0 commit comments