Skip to content

format percentage test#2

Open
zaibkhan wants to merge 1 commit into
12.xfrom
feature-number-fix-1
Open

format percentage test#2
zaibkhan wants to merge 1 commit into
12.xfrom
feature-number-fix-1

Conversation

@zaibkhan

@zaibkhan zaibkhan commented Sep 1, 2025

Copy link
Copy Markdown
Owner

This PR adds a new formatPercentage method to the Number class that allows formatting numbers as percentages with customizable precision and locale support.

Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 1, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 1, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 1, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 1, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 2, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 4, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 5, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 5, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 9, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 9, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 9, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
Repository owner deleted a comment from codoki-pr-intelligence-staging Bot Sep 10, 2025
@codoki-pr-intelligence-staging

codoki-pr-intelligence-staging Bot commented Sep 10, 2025

Copy link
Copy Markdown

Codoki PR Review

Summary: Fix percentage formatting logic, ensure correct input handling and output.
What’s good: The method introduces a useful feature for formatting numbers as percentages with locale support.
Review Status: ✅ Safe to merge

Issues (Medium)

Severity Issue Why it matters
Medium Correctness — Improve input validation for non-numeric values …/Support/Number.php
The current input validation only checks if the input is numeric. Consider throwing an exception for non-numeric input to align with the class's error-handling practices and provide clearer feedback to the caller.
Medium Correctness — Clarify percentage input handling …/Support/Number.php
The division by 100 assumes the input is a percentage value (e.g., 12.34 becomes 0.1234). Ensure this behavior is documented and consistent with the method's intent.

Showing up to 2 medium issue(s). See inline suggestions for more details.

Key Feedback (click to expand)
  • Needs improvement: Ensure input validation and output consistency by aligning with existing methods.
  • Testing: Consider adding tests for edge cases like non-numeric input and locale variations.
  • Documentation: Document the expected input range and behavior for non-numeric values.
  • Compatibility: Ensure the method aligns with existing locale handling in the class.
  • Open questions: Should the method handle non-numeric input more explicitly, perhaps by throwing an exception?

Confidence: 4/5 — Looks good; minor fixes (2 medium)

React with 👍 or 👎 if you found this review useful.

@codoki-pr-intelligence-staging

Copy link
Copy Markdown

Codoki PR Review

Almost there! 🚀 We’ll run this review once you’re connected to Codoki.

Quick setup (≈2 minutes):

  1. Sign up at codoki.ai with your GitHub (free).
  2. If your team already uses Codoki, ask an admin to invite you (Codoki → Members). Otherwise create a workspace and connect this repo.
  3. Re-run checks on this PR.

What you’ll get:

  • ✅ 25 free PR reviews / month
  • 🧠 Context-aware reviews that use your framework & rules
  • ⚙️ Unlimited custom rules and team configs
  • 🚀 Up to 5× faster merges with inline suggestions

Need help? info@codoki.ai

*/
public static function formatPercentage($number, $precision = 2, $locale = null)
{
if (!is_numeric($number)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔷 Medium: The current input validation only checks if the input is numeric. Consider throwing an exception for non-numeric input to align with the class's error-handling practices and provide clearer feedback to the caller.

$formatter = new NumberFormatter($locale ?? app()->getLocale(), NumberFormatter::PERCENT);
$formatter->setAttribute(NumberFormatter::FRACTION_DIGITS, $precision);

return $formatter->format($number / 100);

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🔷 Medium: The division by 100 assumes the input is a percentage value (e.g., 12.34 becomes 0.1234). Ensure this behavior is documented and consistent with the method's intent.

Suggested change
return $formatter->format($number / 100);
return $formatter->format($number);

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