Skip to content

Conversation

othercodes
Copy link
Contributor

No description provided.

@othercodes othercodes requested a review from Copilot October 13, 2025 09:23
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR refactors the IsModel class to reduce cognitive complexity by extracting parameter validation logic into a separate method and improves exception handling by replacing RuntimeException with a more specific InstantiationException.

  • Extracted parameter type validation into a dedicated validateParameterType method
  • Replaced generic RuntimeException with domain-specific InstantiationException
  • Simplified control flow by inverting condition logic and using early returns
Comments suppressed due to low confidence (1)

src/IsModel.php:151

  • Variables $isValid and $expectedTypes are used without being declared in this scope after the refactoring. These variables need to be declared before use.
        if ($type instanceof ReflectionNamedType) {
            // Single type
            $isValid = self::validateType($value, $type->getName(), $type->allowsNull());
            $expectedTypes = $type->getName();

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Copy link

@othercodes othercodes merged commit 4f81c8a into main Oct 13, 2025
6 checks passed
@othercodes othercodes deleted the fix/reduce-cognitive-complexity-and-generic-exceptions branch October 13, 2025 22:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant