| Total Complexity | 10 |
| Total Lines | 67 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 7 | abstract class AbstractValidator implements \Hryvinskyi\QuoteAddressValidator\Model\ValidationInterface |
||
| 8 | { |
||
| 9 | /** |
||
| 10 | * @var ConfigInterface |
||
| 11 | */ |
||
| 12 | private $config; |
||
| 13 | |||
| 14 | public function __construct(ConfigInterface $config) |
||
| 15 | { |
||
| 16 | $this->config = $config; |
||
| 17 | } |
||
| 18 | |||
| 19 | /** |
||
| 20 | * @return ConfigInterface |
||
| 21 | */ |
||
| 22 | public function getConfig(): ConfigInterface |
||
| 25 | } |
||
| 26 | |||
| 27 | /** |
||
| 28 | * Check string for stop words |
||
| 29 | * |
||
| 30 | * @param string $string |
||
| 31 | * @param array $stopWords |
||
| 32 | * @return bool True if the string does not contain stop words |
||
| 33 | */ |
||
| 34 | public function checkStringForStopWords(string $string, array $stopWords): bool |
||
| 35 | { |
||
| 36 | foreach ($stopWords as $stopWord) { |
||
| 37 | if (stripos($string, $stopWord) !== false) { |
||
| 38 | return false; |
||
| 39 | } |
||
| 40 | } |
||
| 41 | |||
| 42 | return true; |
||
| 43 | } |
||
| 44 | |||
| 45 | /** |
||
| 46 | * Validate the value |
||
| 47 | * |
||
| 48 | * @param string $value |
||
| 49 | * @param string $pattern |
||
| 50 | * @param array $stopWords |
||
| 51 | * @return bool True if the value is valid |
||
| 52 | */ |
||
| 53 | public function validate(string $value, string $pattern, array $stopWords): bool |
||
| 68 | } |
||
| 69 | |||
| 70 | /** |
||
| 71 | * @inheritDoc |
||
| 72 | */ |
||
| 73 | abstract public function execute(\Magento\Quote\Api\Data\AddressInterface $address): bool; |
||
| 74 | } |
||
| 75 |
The
breakstatement is not necessary if it is preceded for example by areturnstatement:If you would like to keep this construct to be consistent with other
casestatements, you can safely mark this issue as a false-positive.