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

fractalzombie / frzb-metrics-power / 8450610897

27 Mar 2024 10:55AM UTC coverage: 74.436% (+6.0%) from 68.421%
8450610897

push

github

fractalzombie
[MetricsPower] Added unit and feature tests, Added LoggerOptions attribute

16 of 18 new or added lines in 8 files covered. (88.89%)

3 existing lines in 1 file now uncovered.

99 of 133 relevant lines covered (74.44%)

8.89 hits per line

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

50.0
/Helper/MetricalHelper.php
1
<?php
2

3
declare(strict_types=1);
4

5
/**
6
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
7
 * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
8
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
9
 *
10
 * Copyright (c) 2024 Mykhailo Shtanko fractalzombie@gmail.com
11
 *
12
 * For the full copyright and license information, please view the LICENSE.MD
13
 * file that was distributed with this source code.
14
 */
15

16
namespace FRZB\Component\MetricsPower\Helper;
17

18
use Fp\Collections\ArrayList;
19
use FRZB\Component\MetricsPower\Attribute\Metrical;
20
use FRZB\Component\MetricsPower\Attribute\OptionsInterface as Option;
21
use FRZB\Component\MetricsPower\Attribute\PrometheusOptions;
22
use FRZB\Component\MetricsPower\Traits\WithPrivateEmptyConstructor;
23
use JetBrains\PhpStorm\Immutable;
24

25
/** @internal */
26
#[Immutable]
27
final class MetricalHelper
28
{
29
    use WithPrivateEmptyConstructor;
30

31
    public static function isMetrical(object|string $target): bool
32
    {
33
        return AttributeHelper::hasAttribute($target, Metrical::class);
×
34
    }
35

36
    public static function getMetrical(object|string $target): array
37
    {
38
        return AttributeHelper::getAttributes($target, Metrical::class);
9✔
39
    }
40

41
    public static function getFirstMetrical(object|string $target): ?Metrical
42
    {
43
        return ArrayList::collect(self::getMetrical($target))
9✔
44
            ->firstElement()
9✔
45
            ->get();
9✔
46
    }
47

48
    /** @return array<Option> */
49
    public static function getOptions(object|string $target): array
50
    {
UNCOV
51
        return ArrayList::collect(self::getMetrical($target))
×
UNCOV
52
            ->map(static fn (Metrical $metrical) => $metrical->options)
×
UNCOV
53
            ->flatten()
×
NEW
54
            ->toList();
×
55
    }
56

57
    public static function getCounterName(PrometheusOptions $options): string
58
    {
59
        return str_replace('-', '_', "{$options->topic}-{$options->name}");
27✔
60
    }
61
}
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