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

mborne / remote-git / 14753195534

30 Apr 2025 11:11AM UTC coverage: 80.124% (-1.5%) from 81.624%
14753195534

push

github

web-flow
Merge pull request #33 from mborne/31-visibility

add getVisibility method

6 of 16 new or added lines in 4 files covered. (37.5%)

387 of 483 relevant lines covered (80.12%)

2.63 hits per line

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

70.59
/src/Gitlab/GitlabProject.php
1
<?php
2

3
namespace MBO\RemoteGit\Gitlab;
4

5
use MBO\RemoteGit\ProjectInterface;
6
use MBO\RemoteGit\ProjectVisibility;
7
use RuntimeException;
8

9
/**
10
 * Common project properties between different git project host (gitlab, github, etc.).
11
 *
12
 * @author mborne
13
 */
14
class GitlabProject implements ProjectInterface
15
{
16
    /**
17
     * @param array<string,mixed> $rawMetadata
18
     */
19
    public function __construct(private array $rawMetadata)
20
    {
21
    }
3✔
22

23
    public function getId(): string
24
    {
25
        return $this->rawMetadata['id'];
3✔
26
    }
27

28
    public function getName(): string
29
    {
30
        return $this->rawMetadata['path_with_namespace'];
3✔
31
    }
32

33
    public function getDefaultBranch(): ?string
34
    {
35
        if (!isset($this->rawMetadata['default_branch'])) {
3✔
36
            return null;
1✔
37
        }
38

39
        return $this->rawMetadata['default_branch'];
3✔
40
    }
41

42
    public function getHttpUrl(): string
43
    {
44
        return $this->rawMetadata['http_url_to_repo'];
2✔
45
    }
46

47
    public function isArchived(): bool
48
    {
49
        return $this->rawMetadata['archived'];
2✔
50
    }
51

52
    public function getVisibility(): ?ProjectVisibility
53
    {
54
        switch ($this->rawMetadata['visibility']) {
2✔
55
            case 'public':
2✔
56
                return ProjectVisibility::PUBLIC;
2✔
NEW
57
            case 'private':
×
NEW
58
                return ProjectVisibility::PRIVATE;
×
NEW
59
            case 'internal':
×
NEW
60
                return ProjectVisibility::INTERNAL;
×
61
            default:
NEW
62
                throw new RuntimeException("Unknown visibility: {$this->rawMetadata['visibility']}");
×
63
        }
64
    }
65

66
    public function getRawMetadata(): array
67
    {
68
        return $this->rawMetadata;
2✔
69
    }
70
}
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