src/AbstractDTOCollection.php
private function verifyElementsType(array $elements): void
    {
        $allowedType = $this->getAllowedType();
        if ($allowedType !== DTO::class
            && (!\class_exists($allowedType) || !\in_array(DTO::class, \class_implements($allowedType), true))
        ) {
            throw new InvalidCollectionTypeException(\sprintf(
                'Allowed class type for %s should be a %s, %s given',
                static::class,
                DTO::class,
                $allowedType
            ));
        }

        foreach ($elements as $element) {
            if (!\is_object($element) || !\is_a($element, $allowedType)) {
                throw new InvalidParameterException(\sprintf(
                    'All elements of %s should be instances of %s, %s given',
                    static::class,
                    $allowedType,
                    \is_object($element) ? \get_class($element) : \gettype($element)
                ));
            }
        }
    }
private function verifyElementsType(array $elements): void
    {
        $allowedType = $this->getAllowedType();
        if ($allowedType !== DTO::class
            && (!\class_exists($allowedType) || !\in_array(DTO::class, \class_implements($allowedType), true))
        ) {
            throw new InvalidCollectionTypeException(\sprintf(
                'Allowed class type for %s should be a %s, %s given',
                static::class,
                DTO::class,
                $allowedType
            ));
        }

        foreach ($elements as $element) {
            if (!\is_object($element) || !\is_a($element, $allowedType)) {
                throw new InvalidParameterException(\sprintf(
                    'All elements of %s should be instances of %s, %s given',
                    static::class,
                    $allowedType,
                    \is_object($element) ? \get_class($element) : \gettype($element)
                ));
            }
        }
    }
private function verifyElementsType ( array $ elements ) : void { $ allowedType = $ this -> getAllowedType ( ) ; if ( $ allowedType !== DTO :: class && ( ! \ class_exists ( $ allowedType ) || ! \ in_array ( DTO :: class , \ class_implements ( $ allowedType ) , true ) ) ) { throw new InvalidCollectionTypeException ( \ sprintf ( 'Allowed class type for %s should be a %s, %s given' , static :: class , DTO :: class , $ allowedType ) ) ; } foreach ( $ elements as $ element ) { if ( ! \ is_object ( $ element ) || ! \ is_a ( $ element , $ allowedType ) ) { throw new InvalidParameterException ( \ sprintf ( 'All elements of %s should be instances of %s, %s given' , static :: class , $ allowedType , \ is_object ( $ element ) ? \ get_class ( $ element ) : \ gettype ( $ element ) ) ) ; } } }
Verify collection elements type.

@param mixed[] $elements

@throws InvalidCollectionTypeException
@throws InvalidParameterException
Verify collection elements type .