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

php-bug-catcher / bug-catcher / 11181028058

04 Oct 2024 01:40PM UTC coverage: 86.721% (+0.02%) from 86.701%
11181028058

push

github

tito10047
Fix 16 DashboardImportance.php work per project

12 of 13 new or added lines in 2 files covered. (92.31%)

849 of 979 relevant lines covered (86.72%)

13.79 hits per line

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

92.0
/src/Service/DashboardImportance.php
1
<?php
2
/**
3
 * Created by PhpStorm.
4
 * User: Jozef Môstka
5
 * Date: 26. 7. 2024
6
 * Time: 22:28
7
 */
8
namespace BugCatcher\Service;
9

10
use BugCatcher\Entity\Project;
11
use JetBrains\PhpStorm\ArrayShape;
12
use BugCatcher\Entity\Notifier;
13
use BugCatcher\Enum\Importance;
14
use Symfony\Component\DependencyInjection\Attribute\Autowire;
15

16
final class DashboardImportance
17
{
18

19
        public array $importance = [];
20

21
        public function __construct(
22
                #[Autowire(param: 'kernel.cache_dir')]
23
                private readonly string $cacheDir
24
        ) {}
10✔
25

26
    public function upgradeHigher(string $group, Project $project, Importance $importance, Notifier $notifier): void
27
    {
28
        $current = $this->importance[$group][$project->getId()->toString()] ??
6✔
29
            $this->load($group, $project, $importance, $notifier)[$project->getId()->toString()];
6✔
30
        if ($importance->isHigherThan($current["importance"])) {
6✔
31
                        $current = [
5✔
32
                                "importance" => $importance,
5✔
33
                                "notifier"   => $notifier,
5✔
34
                        ];
5✔
35
                }
36
        $this->importance[$group][$project->getId()->toString()] = $current;
6✔
37
        }
38

39
        public function save(string $group): void {
40
                $importance = $this->importance[$group]??null;
6✔
41
                if ($importance === null) {
6✔
42
                        return;
×
43
                }
44
                $group = substr(md5($group), 0, 8);
6✔
45
                file_put_contents($this->cacheDir . "/importance-$group.txt", serialize($importance));
6✔
46
        }
47

48
    #[ArrayShape([
49
        "string" => [
50
            'importance' => "BugCatcher\Enum\Importance",
51
            'notifier' => "BugCatcher\Entity\Notifier"
52
        ]
53
    ])]
54
    public function load(
55
        string $group,
56
        Project $defaultProject = null,
57
        $defaultImportance = null,
58
        $defaultNotifier = null
59
    ): ?array
60
    {
61
                $group = substr(md5($group), 0, 8);
7✔
62
                if (!file_exists($this->cacheDir . "/importance-$group.txt")) {
7✔
63
            if ($defaultProject === null) {
7✔
NEW
64
                return [];
×
65
            }
66
            return [
7✔
67
                $defaultProject->getId()->toString() => [
7✔
68
                    "importance" => $defaultImportance,
7✔
69
                    "notifier" => $defaultNotifier
7✔
70
                ]
7✔
71
            ];
7✔
72
                }
73

74
                return unserialize(file_get_contents($this->cacheDir . "/importance-$group.txt"));
6✔
75
        }
76
}
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