1 | <?php |
||||
2 | |||||
3 | declare(strict_types=1); |
||||
4 | |||||
5 | namespace Loevgaard\SyliusBarcodePlugin\BarcodeChecker; |
||||
6 | |||||
7 | use Loevgaard\SyliusBarcodePlugin\Event\PostBarcodeCheckEvent; |
||||
8 | use Loevgaard\SyliusBarcodePlugin\Event\PreBarcodeCheckEvent; |
||||
9 | use Loevgaard\SyliusBarcodePlugin\Model\BarcodeAwareInterface; |
||||
10 | use Symfony\Component\EventDispatcher\LegacyEventDispatcherProxy; |
||||
11 | use Symfony\Contracts\EventDispatcher\EventDispatcherInterface; |
||||
12 | use violuke\Barcodes\BarcodeValidator; |
||||
13 | |||||
14 | final class BarcodeChecker implements BarcodeCheckerInterface |
||||
15 | { |
||||
16 | /** @var LegacyEventDispatcherProxy */ |
||||
17 | private $eventDispatcher; |
||||
18 | |||||
19 | public function __construct(EventDispatcherInterface $eventDispatcher) |
||||
20 | { |
||||
21 | $this->eventDispatcher = LegacyEventDispatcherProxy::decorate($eventDispatcher); |
||||
22 | } |
||||
23 | |||||
24 | public function check(BarcodeAwareInterface $barcodeAware): void |
||||
25 | { |
||||
26 | $this->eventDispatcher->dispatch(new PreBarcodeCheckEvent($barcodeAware), PreBarcodeCheckEvent::NAME); |
||||
0 ignored issues
–
show
|
|||||
27 | |||||
28 | $validator = new BarcodeValidator($barcodeAware->getBarcode()); |
||||
29 | $valid = (bool) $validator->isValid(); |
||||
30 | |||||
31 | $barcodeAware->markBarcodeAsChecked($valid); |
||||
32 | |||||
33 | $this->eventDispatcher->dispatch(new PostBarcodeCheckEvent($barcodeAware, $valid, (string) $validator->getType()), PostBarcodeCheckEvent::NAME); |
||||
0 ignored issues
–
show
The constant
Loevgaard\SyliusBarcodeP...BarcodeCheckEvent::NAME has been deprecated: will be removed in v2
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
This class constant has been deprecated. The supplier of the class has supplied an explanatory message. The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead. ![]() |
|||||
34 | } |
||||
35 | } |
||||
36 |
This class constant has been deprecated. The supplier of the class has supplied an explanatory message.
The explanatory message should give you some clue as to whether and when the constant will be removed from the class and what other constant to use instead.