Skip to content
Permalink
Browse files

Mark classes as immutable when possible

  • Loading branch information...
LeSuisse committed Sep 13, 2019
1 parent 7ec8f14 commit 8dbcc49e92eff7de3b6b340b3c492b91032326fb
@@ -13,6 +13,7 @@
/**
* @template TLabelNames of LabelNames
* @psalm-immutable
*/
abstract class Metric
{
@@ -4,6 +4,9 @@
namespace Enalean\Prometheus;
/**
* @psalm-immutable
*/
final class MetricFamilySamples
{
/** @var string */
@@ -43,11 +43,17 @@ public static function requestFailure(RequestInterface $request, ClientException
return new self($request, null, $clientException);
}
/**
* @psalm-pure
*/
public function getRequest() : RequestInterface
{
return $this->request;
}
/**
* @psalm-pure
*/
public function getResponse() : ?ResponseInterface
{
return $this->response;
@@ -10,6 +10,8 @@ interface MetricsRenderer
{
/**
* @param MetricFamilySamples[] $metrics
*
* @psalm-pure
*/
public function render(array $metrics) : string;
@@ -14,6 +14,9 @@
use function strcmp;
use function usort;
/**
* @psalm-immutable
*/
final class RenderTextFormat implements MetricsRenderer
{
private const MIME_TYPE = 'text/plain; version=0.0.4';
@@ -4,6 +4,9 @@
namespace Enalean\Prometheus;
/**
* @psalm-immutable
*/
final class Sample
{
/** @var string */
@@ -8,6 +8,9 @@
use function count;
use function sprintf;
/**
* @psalm-immutable
*/
final class HistogramLabelNames implements LabelNames
{
private const RESERVED_LABEL_HISTOGRAM = 'le';
@@ -10,6 +10,9 @@
use function sprintf;
use function strpos;
/**
* @psalm-immutable
*/
final class MetricLabelNames implements LabelNames
{
private const LABEL_NAME_REGEX = '/^[a-zA-Z_][a-zA-Z0-9_]*$/';
@@ -8,6 +8,9 @@
use function preg_match;
use function sprintf;
/**
* @psalm-immutable
*/
final class MetricName
{
private const METRIC_NAME_REGEX = '/^[a-zA-Z_:][a-zA-Z0-9_:]*$/';

0 comments on commit 8dbcc49

Please sign in to comment.
You can’t perform that action at this time.