AbstractValidationRule.php 608 Bytes
Newer Older
Ketan's avatar
Ketan committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
<?php
namespace GraphQL\Validator\Rules;

use GraphQL\Validator\ValidationContext;

abstract class AbstractValidationRule
{
    protected $name;

    public function getName()
    {
        return $this->name ?: get_class($this);
    }

    public function __invoke(ValidationContext $context)
    {
        return $this->getVisitor($context);
    }

    /**
     * Returns structure suitable for GraphQL\Language\Visitor
     *
     * @see \GraphQL\Language\Visitor
     * @param ValidationContext $context
     * @return array
     */
    abstract public function getVisitor(ValidationContext $context);
}