briannesbitt / Carbon

@@ -890,7 +890,7 @@
Loading
890 890
        switch (true) {
891 891
            case isset($formats[$name]):
892 892
                $format = $formats[$name];
893 -
                $method = substr($format, 0, 1) === '%' ? 'formatLocalized' : 'rawFormat';
893 +
                $method = str_starts_with($format, '%') ? 'formatLocalized' : 'rawFormat';
894 894
                $value = $this->$method($format);
895 895
896 896
                return is_numeric($value) ? (int) $value : $value;
@@ -1132,7 +1132,7 @@
Loading
1132 1132
            case 'microseconds':
1133 1133
            case 'microsecond':
1134 1134
            case 'micro':
1135 -
                if (substr($name, 0, 5) === 'milli') {
1135 +
                if (str_starts_with($name, 'milli')) {
1136 1136
                    $value *= 1000;
1137 1137
                }
1138 1138
@@ -1527,7 +1527,7 @@
Loading
1527 1527
     */
1528 1528
    public function setTimeFromTimeString($time)
1529 1529
    {
1530 -
        if (strpos($time, ':') === false) {
1530 +
        if (!str_contains($time, ':')) {
1531 1531
            $time .= ':0';
1532 1532
        }
1533 1533
@@ -2537,7 +2537,7 @@
Loading
2537 2537
2538 2538
        $unit = rtrim($method, 's');
2539 2539
2540 -
        if (substr($unit, 0, 2) === 'is') {
2540 +
        if (str_starts_with($unit, 'is')) {
2541 2541
            $word = substr($unit, 2);
2542 2542
2543 2543
            if (\in_array($word, static::$days)) {
@@ -2575,7 +2575,7 @@
Loading
2575 2575
        if ($action === 'add' || $action === 'sub') {
2576 2576
            $unit = substr($unit, 3);
2577 2577
2578 -
            if (substr($unit, 0, 4) === 'Real') {
2578 +
            if (str_starts_with($unit, 'Real')) {
2579 2579
                $unit = static::singularUnit(substr($unit, 4));
2580 2580
2581 2581
                return $this->{"${action}RealUnit"}($unit, ...$parameters);
@@ -2617,7 +2617,7 @@
Loading
2617 2617
            }
2618 2618
        }
2619 2619
2620 -
        if (substr($unit, 0, 9) === 'isCurrent') {
2620 +
        if (str_starts_with($unit, 'isCurrent')) {
2621 2621
            try {
2622 2622
                return $this->isCurrentUnit(strtolower(substr($unit, 9)));
2623 2623
            } catch (BadComparisonUnitException | BadMethodCallException $exception) {
@@ -2625,7 +2625,7 @@
Loading
2625 2625
            }
2626 2626
        }
2627 2627
2628 -
        if (substr($method, -5) === 'Until') {
2628 +
        if (str_ends_with($method, 'Until')) {
2629 2629
            try {
2630 2630
                $unit = static::singularUnit(substr($method, 0, -5));
2631 2631

@@ -37,7 +37,7 @@
Loading
37 37
            return $type;
38 38
        }
39 39
40 -
        if (strpos($type, '(') !== false) {
40 +
        if (str_contains($type, '(')) {
41 41
            return preg_replace('/\(\d+\)/', "($precision)", $type);
42 42
        }
43 43

@@ -355,7 +355,7 @@
Loading
355 355
        }
356 356
357 357
        // If subtag (ex: en_CA) first load the macro (ex: en) to have a fallback
358 -
        if (strpos($locale, '_') !== false &&
358 +
        if (str_contains($locale, '_') &&
359 359
            $this->loadMessagesFromFile($macroLocale = preg_replace('/^([^_]+).*$/', '$1', $locale))
360 360
        ) {
361 361
            parent::setLocale($macroLocale);

@@ -2280,7 +2280,7 @@
Loading
2280 2280
     */
2281 2281
    protected function isCarbonPredicateMethod($callable)
2282 2282
    {
2283 -
        return \is_string($callable) && substr($callable, 0, 2) === 'is' &&
2283 +
        return \is_string($callable) && str_starts_with($callable, 'is') &&
2284 2284
            (method_exists($this->dateClass, $callable) || ([$this->dateClass, 'hasMacro'])($callable));
2285 2285
    }
2286 2286

@@ -177,7 +177,7 @@
Loading
177 177
            $numbers = number_format($numbers, $decimals, '.', '');
178 178
        }
179 179
180 -
        $sign = substr($numbers, 0, 1) === '-' ? -1 : 1;
180 +
        $sign = str_starts_with($numbers, '-') ? -1 : 1;
181 181
        $integer = 0;
182 182
        $decimal = 0;
183 183

@@ -41,7 +41,7 @@
Loading
41 41
    's' => ':count seg.',
42 42
    'ago' => 'hai :time',
43 43
    'from_now' => function ($time) {
44 -
        if (substr($time, 0, 2) === 'un') {
44 +
        if (str_starts_with($time, 'un')) {
45 45
            return "n$time";
46 46
        }
47 47

@@ -77,7 +77,7 @@
Loading
77 77
        }
78 78
79 79
        // Work-around for PHP bug https://bugs.php.net/bug.php?id=67127
80 -
        if (strpos((string) .1, '.') === false) {
80 +
        if (!str_contains((string) .1, '.')) {
81 81
            $locale = setlocale(LC_NUMERIC, '0');
82 82
            setlocale(LC_NUMERIC, 'C');
83 83
        }

@@ -996,7 +996,7 @@
Loading
996 996
     */
997 997
    public function get($name)
998 998
    {
999 -
        if (substr($name, 0, 5) === 'total') {
999 +
        if (str_starts_with($name, 'total')) {
1000 1000
            return $this->total(substr($name, 5));
1001 1001
        }
1002 1002
Files Complexity Coverage
src/Carbon 2,129 100.00%
Project Totals (886 files) 2129 100.00%

No yaml found.

Create your codecov.yml to customize your Codecov experience

Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading