add SMSpanel

This commit is contained in:
2026-07-04 11:55:10 +03:30
parent 1ce2e73ea9
commit 163097f42a
22 changed files with 6683 additions and 2214 deletions
@@ -0,0 +1,37 @@
<?php
namespace App\Services\SmsBilling;
class SmsSegmentCalculator
{
private const PERSIAN_LIMITS = [70, 64, 67];
public function countParts(string $text): int
{
$length = mb_strlen(trim($text), 'UTF-8');
if ($length <= 0) {
return 0;
}
$first = self::PERSIAN_LIMITS[0];
$second = self::PERSIAN_LIMITS[1];
$rest = self::PERSIAN_LIMITS[2];
if ($length <= $first) {
return 1;
}
if ($length <= $first + $second) {
return 2;
}
$thirdThreshold = $first + $second + $rest;
if ($length <= $thirdThreshold) {
return 3;
}
return 3 + (int) ceil(($length - $thirdThreshold) / $rest);
}
}