• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

chico-rei / correios-php / 18193020552

02 Oct 2025 12:31PM UTC coverage: 5.302% (-0.02%) from 5.317%
18193020552

push

github

Matheus Marques
Fix Date parse

0 of 15 new or added lines in 5 files covered. (0.0%)

57 of 1075 relevant lines covered (5.3%)

0.06 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

0.0
/src/Util.php
1
<?php
2

3
namespace ChicoRei\Packages\Correios;
4

5
use Carbon\Carbon;
6

7
class Util
8
{
9
    /**
10
     * Remove all null values from array
11
     */
12
    public static function cleanArray(?array &$array): ?array
13
    {
14
        if (is_null($array)) {
×
15
            return null;
×
16
        }
17

18
        foreach ($array as $key => &$value) {
×
19
            if (is_null($value)) {
×
20
                unset($array[$key]);
×
21
            } else {
22
                if (is_array($value)) {
×
23
                    Util::cleanArray($value);
×
24
                }
25
            }
26
        }
27

28
        return $array;
×
29
    }
30

31
    /**
32
     * Return equivalent amount in cents
33
     */
34
    public static function parseDate($dateToParse)
35
    {
NEW
36
        if (is_null($dateToParse)) {
×
NEW
37
            return null;
×
38
        }
39

40
        try {
NEW
41
            return Carbon::parse($dateToParse, 'America/Sao_Paulo');
×
NEW
42
        } catch (\Exception $e) {
×
43
            // Try to remove nanoseconds
NEW
44
            return Carbon::parse(mb_substr($dateToParse, 0, -3), 'America/Sao_Paulo');
×
45
        }
46
    }
47
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc