-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Resolve CMS-912 Closes CMS-912 See merge request ecommerce_modules/wordpress/plugin!5
- Loading branch information
Showing
14 changed files
with
300 additions
and
214 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace Cdek\Contracts; | ||
|
||
use InvalidArgumentException; | ||
|
||
abstract class FieldsetContract | ||
{ | ||
protected const FIELDS = []; | ||
|
||
final public function getFieldsNames(): array | ||
{ | ||
return array_keys($this->getFields()); | ||
} | ||
|
||
abstract protected function getFields(): array; | ||
|
||
final public function isRequiredField(string $fieldName): bool | ||
{ | ||
$fieldList = $this->getFields(); | ||
if (!isset($fieldList[$fieldName])) { | ||
throw new InvalidArgumentException('Field not found'); | ||
} | ||
|
||
return $fieldList[$fieldName]['required'] ?? false; | ||
} | ||
|
||
abstract public function isApplicable(): bool; | ||
|
||
final public function getFieldDefinition(string $fieldName): array | ||
{ | ||
$fieldList = $this->getFields(); | ||
if (!isset($fieldList[$fieldName])) { | ||
throw new InvalidArgumentException('Field not found'); | ||
} | ||
|
||
return $fieldList[$fieldName]; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.