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

mimmi20 / laminasviewrenderer-bootstrap-form / 12160906017

04 Dec 2024 01:37PM UTC coverage: 97.314%. Remained the same
12160906017

push

github

web-flow
Merge pull request #310 from mimmi20/updates

upgrade to PHP 8.3

60 of 61 new or added lines in 40 files covered. (98.36%)

38 existing lines in 7 files now uncovered.

2174 of 2234 relevant lines covered (97.31%)

25.52 hits per line

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

93.1
/src/FormDateSelectTrait.php
1
<?php
2

3
/**
4
 * This file is part of the mimmi20/laminasviewrenderer-bootstrap-form package.
5
 *
6
 * Copyright (c) 2021-2024, Thomas Mueller <mimmi20@live.de>
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11

12
declare(strict_types = 1);
13

14
namespace Mimmi20\LaminasView\BootstrapForm;
15

16
use DateTime;
17
use IntlDateFormatter;
18
use Override;
19

20
trait FormDateSelectTrait
21
{
22
    /**
23
     * Create a key => value options for days
24
     *
25
     * @param string $pattern Pattern to use for days
26
     *
27
     * @return array<int|string, array<string, string>>
28
     *
29
     * @throws void
30
     */
31
    #[Override]
3✔
32
    protected function getDaysOptions(string $pattern): array
33
    {
34
        $keyFormatter   = new IntlDateFormatter(
3✔
35
            $this->getLocale(),
3✔
36
            IntlDateFormatter::NONE,
3✔
37
            IntlDateFormatter::NONE,
3✔
38
            null,
3✔
39
            null,
3✔
40
            'dd',
3✔
41
        );
3✔
42
        $valueFormatter = new IntlDateFormatter(
3✔
43
            $this->getLocale(),
3✔
44
            IntlDateFormatter::NONE,
3✔
45
            IntlDateFormatter::NONE,
3✔
46
            null,
3✔
47
            null,
3✔
48
            $pattern,
3✔
49
        );
3✔
50
        $date           = new DateTime('1970-01-01');
3✔
51

52
        $result = [];
3✔
53

54
        for ($day = 1; 31 >= $day; ++$day) {
3✔
55
            $key = $keyFormatter->format($date->getTimestamp());
3✔
56

57
            if ($key === false) {
3✔
UNCOV
58
                continue;
×
59
            }
60

61
            $value = $valueFormatter->format($date->getTimestamp());
3✔
62

63
            if ($value === false) {
3✔
UNCOV
64
                continue;
×
65
            }
66

67
            $result[$key] = ['value' => $key, 'label' => $value];
3✔
68

69
            $date->modify('+1 day');
3✔
70
        }
71

72
        return $result;
3✔
73
    }
74
}
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

© 2025 Coveralls, Inc