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

php-bug-catcher / bug-catcher / 10983401053

22 Sep 2024 06:21PM UTC coverage: 76.842% (+1.9%) from 74.904%
10983401053

push

github

tito10047
created tests for Importance.php

5 of 7 new or added lines in 4 files covered. (71.43%)

803 of 1045 relevant lines covered (76.84%)

11.43 hits per line

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

79.49
/src/Enum/Importance.php
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Jozef Môstka
5
 * Date: 7. 6. 2024
6
 * Time: 18:55
7
 */
8
namespace BugCatcher\Enum;
9

10
enum Importance: string {
11
        case Normal   = 'normal';
12
        case Low      = 'low';
13
        case Medium   = 'medium';
14
        case High     = 'high';
15
        case Critical = 'critical';
16
        case MamaMia  = 'mama-mia';
17

18
        /** @return array<Importance> */
19
        public static function all(): array {
20
                return [
13✔
21
                        self::Normal,
13✔
22
                        self::Low,
13✔
23
                        self::Medium,
13✔
24
                        self::High,
13✔
25
                        self::Critical,
13✔
26
                        self::MamaMia,
13✔
27
                ];
13✔
28
        }
29

30
    /**
31
     * Determines if this importance is higher than the given importance.
32
     * @param Importance $importance
33
     * @return bool
34
     */
35
    public function isHigherThan(Importance $importance): bool
36
    {
37
                foreach (self::all() as $i) {
10✔
38
                        if ($i === $importance) {
10✔
39
                return true;
10✔
40
                        }
41
                        if ($i === $this) {
10✔
NEW
42
                return false;
×
43
                        }
44
                }
45
        }
46

47
        /**
48
         * Determines if this importance is lover or equal to the given importance.
49
         *
50
         * @param Importance $importance
51
         * @return bool
52
         */
53
    public function isHigherOrEqualThan(Importance $importance): bool
54
    {
55
        return $this === $importance || $this->isHigherThan($importance);
8✔
56
        }
57

58
        public static function min(): Importance {
59
                return self::Normal;
2✔
60
        }
61

62
        public static function max(): Importance {
63
                return self::MamaMia;
2✔
64
        }
65

66
        public function getColor(): BootstrapColor {
67
                return match ($this) {
1✔
68
                        self::Low => BootstrapColor::Secondary,
1✔
69
                        self::Medium => BootstrapColor::Warning,
1✔
70
                        self::High => BootstrapColor::Primary,
1✔
71
                        self::Critical => BootstrapColor::Info,
1✔
72
                        self::MamaMia => BootstrapColor::Danger,
1✔
73
                        default => BootstrapColor::Default,
1✔
74
                };
1✔
75
        }
76

77
        public function lower(): Importance {
78
                return match ($this) {
×
79
                        self::Medium => self::Low,
×
80
                        self::High => self::Medium,
×
81
                        self::Critical => self::High,
×
82
                        self::MamaMia => self::Critical,
×
83
                        default => self::Normal,
×
84
                };
×
85
        }
86

87

88
        public function higher(): Importance {
89
                return match ($this) {
1✔
90
            self::Normal => self::Low,
1✔
91
                        self::Low => self::Medium,
1✔
92
                        self::Medium => self::High,
1✔
93
                        self::High => self::Critical,
1✔
94
                        self::Critical => self::MamaMia,
1✔
95
                        default => self::Normal,
1✔
96
                };
1✔
97
        }
98
}
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