public function getRules(Reflector $reflection): array
    {
        if ($reflection instanceof ReflectionMethod) {
            $key = $reflection->getDeclaringClass()->getName().'::'.$reflection->getName();
        } elseif ($reflection instanceof ReflectionClass) {
            $key = $reflection->getName();
        } elseif ($reflection instanceof ReflectionProperty) {
            $key = $reflection->getDeclaringClass()->getName().'::$'.$reflection->getName();
        } else {
            throw new InvalidArgumentException('Reflection must be an instance of either ReflectionMethod, ReflectionClass or ReflectionProperty.');
        }

        if (!isset($this->cache[$key])) {
            $this->cache[$key] = $this->ruleProvider->getRules($reflection);
        }

        return $this->cache[$key];
    }