briannesbitt / Carbon

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

@@ -41,7 +41,7 @@
Loading
41 41
    's' => ':count seg.',
42 42
    'ago' => 'hai :time',
43 43
    'from_now' => static 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

@@ -2302,7 +2302,7 @@
Loading
2302 2302
     */
2303 2303
    protected function isCarbonPredicateMethod($callable)
2304 2304
    {
2305 -
        return \is_string($callable) && substr($callable, 0, 2) === 'is' &&
2305 +
        return \is_string($callable) && str_starts_with($callable, 'is') &&
2306 2306
            (method_exists($this->dateClass, $callable) || ([$this->dateClass, 'hasMacro'])($callable));
2307 2307
    }
2308 2308

@@ -622,7 +622,7 @@
Loading
622 622
623 623
        if (!isset($units[$unit])) {
624 624
            if (isset($this->$unit)) {
625 -
                return $this->$unit === $this->resolveCarbon($date)->$unit;
625 +
                return $this->resolveCarbon($date)->$unit === $this->$unit;
626 626
            }
627 627
628 628
            if ($this->localStrictModeEnabled ?? static::isStrictModeEnabled()) {
@@ -1001,7 +1001,7 @@
Loading
1001 1001
        ];
1002 1002
1003 1003
        foreach ($units as $unit => [$minimum, $startUnit]) {
1004 -
            if ($median->$unit === $minimum) {
1004 +
            if ($minimum === $median->$unit) {
1005 1005
                $current = $current->startOf($startUnit);
1006 1006
1007 1007
                break;

@@ -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

@@ -821,7 +821,7 @@
Loading
821 821
        switch (true) {
822 822
            case isset($formats[$name]):
823 823
                $format = $formats[$name];
824 -
                $method = substr($format, 0, 1) === '%' ? 'formatLocalized' : 'rawFormat';
824 +
                $method = str_starts_with($format, '%') ? 'formatLocalized' : 'rawFormat';
825 825
                $value = $this->$method($format);
826 826
827 827
                return is_numeric($value) ? (int) $value : $value;
@@ -1065,7 +1065,7 @@
Loading
1065 1065
            case 'microseconds':
1066 1066
            case 'microsecond':
1067 1067
            case 'micro':
1068 -
                if (substr($name, 0, 5) === 'milli') {
1068 +
                if (str_starts_with($name, 'milli')) {
1069 1069
                    $value *= 1000;
1070 1070
                }
1071 1071
@@ -1441,7 +1441,7 @@
Loading
1441 1441
     */
1442 1442
    public function setTimeFromTimeString($time)
1443 1443
    {
1444 -
        if (strpos($time, ':') === false) {
1444 +
        if (!str_contains($time, ':')) {
1445 1445
            $time .= ':0';
1446 1446
        }
1447 1447
@@ -2373,7 +2373,7 @@
Loading
2373 2373
2374 2374
        $unit = rtrim($method, 's');
2375 2375
2376 -
        if (substr($unit, 0, 2) === 'is') {
2376 +
        if (str_starts_with($unit, 'is')) {
2377 2377
            $word = substr($unit, 2);
2378 2378
2379 2379
            if (\in_array($word, static::$days)) {
@@ -2411,7 +2411,7 @@
Loading
2411 2411
        if ($action === 'add' || $action === 'sub') {
2412 2412
            $unit = substr($unit, 3);
2413 2413
2414 -
            if (substr($unit, 0, 4) === 'Real') {
2414 +
            if (str_starts_with($unit, 'Real')) {
2415 2415
                $unit = static::singularUnit(substr($unit, 4));
2416 2416
2417 2417
                return $this->{"${action}RealUnit"}($unit, ...$parameters);
@@ -2453,7 +2453,7 @@
Loading
2453 2453
            }
2454 2454
        }
2455 2455
2456 -
        if (substr($unit, 0, 9) === 'isCurrent') {
2456 +
        if (str_starts_with($unit, 'isCurrent')) {
2457 2457
            try {
2458 2458
                return $this->isCurrentUnit(strtolower(substr($unit, 9)));
2459 2459
            } catch (BadComparisonUnitException | BadMethodCallException $exception) {
@@ -2461,7 +2461,7 @@
Loading
2461 2461
            }
2462 2462
        }
2463 2463
2464 -
        if (substr($method, -5) === 'Until') {
2464 +
        if (str_ends_with($method, 'Until')) {
2465 2465
            try {
2466 2466
                $unit = static::singularUnit(substr($method, 0, -5));
2467 2467

@@ -149,7 +149,7 @@
Loading
149 149
     */
150 150
    public function trans($id, array $parameters = [], $domain = null, $locale = null)
151 151
    {
152 -
        if (null === $domain) {
152 +
        if ($domain === null) {
153 153
            $domain = 'messages';
154 154
        }
155 155
@@ -356,7 +356,7 @@
Loading
356 356
        }
357 357
358 358
        // If subtag (ex: en_CA) first load the macro (ex: en) to have a fallback
359 -
        if (strpos($locale, '_') !== false &&
359 +
        if (str_contains($locale, '_') &&
360 360
            $this->loadMessagesFromFile($macroLocale = preg_replace('/^([^_]+).*$/', '$1', $locale))
361 361
        ) {
362 362
            parent::setLocale($macroLocale);

@@ -1082,7 +1082,7 @@
Loading
1082 1082
     */
1083 1083
    public function get(string $name)
1084 1084
    {
1085 -
        if (substr($name, 0, 5) === 'total') {
1085 +
        if (str_starts_with($name, 'total')) {
1086 1086
            return $this->total(substr($name, 5));
1087 1087
        }
1088 1088

@@ -11,7 +11,7 @@
Loading
11 11
// @codeCoverageIgnoreStart
12 12
if (class_exists('Symfony\\Component\\Translation\\PluralizationRules')) {
13 13
    \Symfony\Component\Translation\PluralizationRules::set(function ($number) {
14 -
        return ((1 == $number % 10) && (11 != $number % 100)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
14 +
        return (($number % 10 == 1) && ($number % 100 != 11)) ? 0 : ((($number % 10 >= 2) && ($number % 10 <= 4) && (($number % 100 < 10) || ($number % 100 >= 20))) ? 1 : 2);
15 15
    }, 'be');
16 16
}
17 17
// @codeCoverageIgnoreEnd
Files Complexity Coverage
src/Carbon 2,070 100.00%
Project Totals (886 files) 2070 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