fractalzombie /
frzb-metrics-power
| 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 [email protected] |
||
| 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\LoggerOptions; |
||
|
0 ignored issues
–
show
|
|||
| 20 | use FRZB\Component\MetricsPower\Attribute\Metrical; |
||
|
0 ignored issues
–
show
The type
FRZB\Component\MetricsPower\Attribute\Metrical was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 21 | use FRZB\Component\MetricsPower\Attribute\OptionsInterface; |
||
| 22 | use FRZB\Component\MetricsPower\Attribute\PrometheusOptions; |
||
|
0 ignored issues
–
show
The type
FRZB\Component\MetricsPo...ibute\PrometheusOptions was not found. Maybe you did not declare it correctly or list all dependencies?
The issue could also be caused by a filter entry in the build configuration.
If the path has been excluded in your configuration, e.g. filter:
dependency_paths: ["lib/*"]
For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths Loading history...
|
|||
| 23 | use FRZB\Component\MetricsPower\Traits\WithPrivateEmptyConstructor; |
||
| 24 | use JetBrains\PhpStorm\Immutable; |
||
| 25 | |||
| 26 | /** @internal */ |
||
| 27 | #[Immutable] |
||
| 28 | final class MetricalHelper |
||
| 29 | { |
||
| 30 | use WithPrivateEmptyConstructor; |
||
| 31 | |||
| 32 | public static function isMetrical(object|string $target): bool |
||
| 33 | { |
||
| 34 | return AttributeHelper::hasAttribute($target, Metrical::class); |
||
| 35 | } |
||
| 36 | |||
| 37 | public static function getMetrical(object|string $target): ?Metrical |
||
| 38 | { |
||
| 39 | return ArrayList::collect(AttributeHelper::getAttributes($target, Metrical::class))->firstElement()->get(); |
||
| 40 | } |
||
| 41 | |||
| 42 | /** @return array<OptionsInterface> */ |
||
| 43 | public static function getOptions(object|string $target): array |
||
| 44 | { |
||
| 45 | return ArrayList::collect(self::getMetrical($target)?->options ?? []) |
||
| 46 | ->toList(); |
||
| 47 | } |
||
| 48 | |||
| 49 | public static function getFirstOptions(object|string $target): ?OptionsInterface |
||
| 50 | { |
||
| 51 | return ArrayList::collect(self::getOptions($target)) |
||
| 52 | ->firstElement() |
||
| 53 | ->getOrElse(new LoggerOptions()); |
||
| 54 | } |
||
| 55 | |||
| 56 | public static function getCounterName(PrometheusOptions $options): string |
||
| 57 | { |
||
| 58 | return StringHelper::toSnakeCase( |
||
| 59 | str_replace('-', '_', "{$options->topic}_{$options->name}") |
||
| 60 | ); |
||
| 61 | } |
||
| 62 | } |
||
| 63 |
The issue could also be caused by a filter entry in the build configuration. If the path has been excluded in your configuration, e.g.
excluded_paths: ["lib/*"], you can move it to the dependency path list as follows:For further information see https://scrutinizer-ci.com/docs/tools/php/php-scrutinizer/#list-dependency-paths