| 1 |  |  | <?php | 
            
                                                                                                            
                            
            
                                    
            
            
                | 2 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 3 |  |  | namespace Obblm\Core\Validator\Constraints; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 4 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 5 |  |  | use Doctrine\Common\Collections\ArrayCollection; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 6 |  |  | use Doctrine\Common\Collections\Criteria; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 7 |  |  | use Obblm\Championship\Entity\Encounter; | 
                            
                    |  |  |  | 
                                                                                        
                                                                                     | 
            
                                                                                                            
                            
            
                                    
            
            
                | 8 |  |  | use Obblm\Core\Helper\Rule\Inducement\Inducement; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 9 |  |  | use Symfony\Component\Form\Exception\UnexpectedTypeException; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 10 |  |  | use Symfony\Component\Validator\Constraint; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 11 |  |  | use Symfony\Component\Validator\ConstraintValidator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 12 |  |  | use Symfony\Contracts\Translation\TranslatorInterface; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 13 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 14 |  |  | class InducementsQuantityValidator extends ConstraintValidator | 
            
                                                                                                            
                            
            
                                    
            
            
                | 15 |  |  | { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 16 |  |  |     private $translator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 17 |  |  |  | 
            
                                                                                                            
                            
            
                                    
            
            
                | 18 |  |  |     public function __construct(TranslatorInterface $translator) | 
            
                                                                                                            
                            
            
                                    
            
            
                | 19 |  |  |     { | 
            
                                                                                                            
                            
            
                                    
            
            
                | 20 |  |  |         $this->translator = $translator; | 
            
                                                                                                            
                            
            
                                    
            
            
                | 21 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 22 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 23 |  |  |     public function validate($value, Constraint $constraint) | 
            
                                                                        
                            
            
                                    
            
            
                | 24 |  |  |     { | 
            
                                                                        
                            
            
                                    
            
            
                | 25 |  |  |         if (!$constraint instanceof InducementsQuantity) { | 
            
                                                                        
                            
            
                                    
            
            
                | 26 |  |  |             throw new UnexpectedTypeException($constraint, InducementsQuantity::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 27 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 28 |  |  |         if (!is_array($value)) { | 
            
                                                                        
                            
            
                                    
            
            
                | 29 |  |  |             throw new UnexpectedTypeException($value, Encounter::class); | 
            
                                                                        
                            
            
                                    
            
            
                | 30 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 31 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 32 |  |  |         $count = []; | 
            
                                                                        
                            
            
                                    
            
            
                | 33 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 34 |  |  |         // Validate each inducement | 
            
                                                                        
                            
            
                                    
            
            
                | 35 |  |  |         foreach ($value as $i => $inducement) { | 
            
                                                                        
                            
            
                                    
            
            
                | 36 |  |  |             /** @var Inducement $inducement */ | 
            
                                                                        
                            
            
                                    
            
            
                | 37 |  |  |             if (!isset($count[$inducement->getKey()])) { | 
            
                                                                        
                            
            
                                    
            
            
                | 38 |  |  |                 $count[$inducement->getKey()] = 0; | 
            
                                                                        
                            
            
                                    
            
            
                | 39 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 40 |  |  |             $count[$inducement->getKey()]++; | 
            
                                                                        
                            
            
                                    
            
            
                | 41 |  |  |             if ($count[$inducement->getKey()] > $inducement->getMax()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 42 |  |  |                 $type = $this->translator->trans((string) $inducement, [], $inducement->getTranslationDomain()); | 
            
                                                                        
                            
            
                                    
            
            
                | 43 |  |  |                 $this->context->buildViolation($constraint->limitMessage) | 
            
                                                                        
                            
            
                                    
            
            
                | 44 |  |  |                     ->setParameter('{{ type }}', $type) | 
            
                                                                        
                            
            
                                    
            
            
                | 45 |  |  |                     ->setParameter('{{ limit }}', $inducement->getMax()) | 
            
                                                                        
                            
            
                                    
            
            
                | 46 |  |  |                     ->addViolation(); | 
            
                                                                        
                            
            
                                    
            
            
                | 47 |  |  |             } | 
            
                                                                        
                            
            
                                    
            
            
                | 48 |  |  |         } | 
            
                                                                        
                            
            
                                    
            
            
                | 49 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 50 |  |  |         // Validate quantity of star players | 
            
                                                                        
                            
            
                                    
            
            
                | 51 |  |  |         $value = new ArrayCollection($value); | 
            
                                                                        
                            
            
                                    
            
            
                | 52 |  |  |         $criteria = (Criteria::create()); | 
            
                                                                        
                            
            
                                    
            
            
                | 53 |  |  |         $criteria->where(Criteria::expr()->eq('type', 'star_players')); | 
            
                                                                        
                            
            
                                    
            
            
                | 54 |  |  |         $criteria->orderBy(['value' => 'ASC']); | 
            
                                                                        
                            
            
                                    
            
            
                | 55 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 56 |  |  |         $starPlayers = $value->matching($criteria); | 
            
                                                                        
                            
            
                                    
            
            
                | 57 |  |  |  | 
            
                                                                        
                            
            
                                    
            
            
                | 58 |  |  |         if ($starPlayers->count() > $constraint->helper->getMaxStarPlayers()) { | 
            
                                                                        
                            
            
                                    
            
            
                | 59 |  |  |             $type = $this->translator->trans($starPlayers->getTranslationType(), [], $starPlayers->getTranslationDomain()); | 
                            
                    |  |  |  | 
                                                                                        
                                                                                            
                                                                                     | 
            
                                                                        
                            
            
                                    
            
            
                | 60 |  |  |             $this->context->buildViolation($constraint->limitMessage) | 
            
                                                                        
                            
            
                                    
            
            
                | 61 |  |  |                 ->setParameter('{{ type }}', $type) | 
            
                                                                        
                            
            
                                    
            
            
                | 62 |  |  |                 ->setParameter('{{ limit }}', $constraint->helper->getMaxStarPlayers()) | 
            
                                                                        
                            
            
                                    
            
            
                | 63 |  |  |                 ->addViolation(); | 
            
                                                                                                            
                            
            
                                    
            
            
                | 64 |  |  |         } | 
            
                                                                                                            
                            
            
                                    
            
            
                | 65 |  |  |     } | 
            
                                                                                                            
                                                                
            
                                    
            
            
                | 66 |  |  | } | 
            
                                                        
            
                                    
            
            
                | 67 |  |  |  | 
            
                        
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths