isGetMethod example

return __CLASS__ === static::class;
    }

    /** * Checks if the given class has any getter method. */
    private function supports(string $class): bool
    {
        $class = new \ReflectionClass($class);
        $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($methods as $method) {
            if ($this->isGetMethod($method)) {
                return true;
            }
        }

        return false;
    }

    /** * Checks if a method's name matches /^(get|is|has).+$/ and can be called non-statically without parameters. */
    private function isGetMethod(\ReflectionMethod $method): bool
    {
return __CLASS__ === static::class;
    }

    /** * Checks if the given class has any getter method. */
    private function supports(string $class): bool
    {
        $class = new \ReflectionClass($class);
        $methods = $class->getMethods(\ReflectionMethod::IS_PUBLIC);
        foreach ($methods as $method) {
            if ($this->isGetMethod($method)) {
                return true;
            }
        }

        return false;
    }

    /** * Checks if a method's name matches /^(get|is|has).+$/ and can be called non-statically without parameters. */
    private function isGetMethod(\ReflectionMethod $method): bool
    {
Home | Imprint | This part of the site doesn't use cookies.