private function checkMethodsAccessibility(): void
    {
        $publicMethods = $this->getClassPublicMethods();
        \sort($publicMethods);

        $allowedPublicMethods = $this->getAllowedPublicMethods();

        foreach (static::$allowedMagicMethods as $magicMethod) {
            if (\array_search($magicMethod, $publicMethods, true) !== false) {
                $allowedPublicMethods[] = $magicMethod;
            }
        }

        \sort($allowedPublicMethods);

        if (\count($publicMethods) > \count($allowedPublicMethods)
            || \count(\array_diff($allowedPublicMethods, $publicMethods)) !== 0
        ) {
            throw new ImmutabilityViolationException(\sprintf(
                'Class %s should not have public methods',
                static::class
            ));
        }
    }