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

visavi / rotor / 28953145791

08 Jul 2026 03:06PM UTC coverage: 32.729% (+0.01%) from 32.717%
28953145791

push

github

visavi
Очистка кеша теперь  чистить все

0 of 1 new or added line in 1 file covered. (0.0%)

2 existing lines in 1 file now uncovered.

1859 of 5680 relevant lines covered (32.73%)

3.81 hits per line

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

66.67
/app/Services/GithubService.php
1
<?php
2

3
namespace App\Services;
4

5
use Illuminate\Support\Facades\Cache;
6
use Illuminate\Support\Facades\Http;
7
use RuntimeException;
8
use Throwable;
9

10
class GithubService
11
{
12
    protected string $baseUrl = 'https://api.github.com/repos/visavi/rotor/';
13
    protected int $defaultCacheTtl = 3600;
14

15
    /**
16
     * Получает последние коммиты
17
     */
18
    public function getLatestCommits(): array
×
19
    {
20
        return Cache::remember('commits', $this->defaultCacheTtl, function () {
×
21
            return $this->fetchGitHubData(
×
22
                endpoint: 'commits',
×
23
                params: ['per_page' => 100]
×
24
            );
×
25
        });
×
26
    }
27

28
    /**
29
     * Get last release
30
     */
31
    public function getLatestRelease(): array
1✔
32
    {
33
        return $this->getLatestReleases()[0] ?? [];
1✔
34
    }
35

36
    /**
37
     * Get last version
38
     */
39
    public function getLatestVersion(): string
1✔
40
    {
41
        $release = $this->getLatestRelease();
1✔
42

43
        return $release['tag_name'] ?? '';
1✔
44
    }
45

46
    /**
47
     * Get last version
48
     */
49
    public function getLatestVersionClean(): string
1✔
50
    {
51
        $version = $this->getLatestVersion();
1✔
52
        $clean = ltrim($version, 'v');
1✔
53

54
        return str_replace(['-alpha', '-beta', '-rc'], '', $clean);
1✔
55
    }
56

57
    /**
58
     * Получает последние релизы
59
     */
60
    public function getLatestReleases(): array
1✔
61
    {
62
        return Cache::remember('releases', $this->defaultCacheTtl, function () {
1✔
63
            return $this->fetchGitHubData(
1✔
64
                endpoint: 'releases',
1✔
65
                params: ['per_page' => 10]
1✔
66
            );
1✔
67
        });
1✔
68
    }
69

70
    /**
71
     * Обращается к GitHub API
72
     */
73
    protected function fetchGitHubData(string $endpoint, array $params = []): array
1✔
74
    {
75
        $headers = [
1✔
76
            'Accept' => 'application/vnd.github+json',
1✔
77
        ];
1✔
78

79
        try {
80
            $response = Http::withHeaders($headers)
1✔
81
                ->timeout(3)
1✔
82
                ->retry(3, 100)
1✔
83
                ->get($this->baseUrl . $endpoint, $params);
1✔
84

85
            if ($response->failed()) {
1✔
86
                throw new RuntimeException(
×
87
                    'GitHub API error: ' . $response->body(),
×
88
                    $response->status()
×
89
                );
×
90
            }
91

92
            return $response->json() ?? [];
1✔
UNCOV
93
        } catch (Throwable) {
×
UNCOV
94
            return [];
×
95
        }
96
    }
97
}
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