summaryrefslogtreecommitdiffstats
path: root/src/Monolog/Processor/UidProcessor.php
diff options
context:
space:
mode:
Diffstat (limited to 'src/Monolog/Processor/UidProcessor.php')
-rw-r--r--src/Monolog/Processor/UidProcessor.php10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/Monolog/Processor/UidProcessor.php b/src/Monolog/Processor/UidProcessor.php
index 812707c..601171b 100644
--- a/src/Monolog/Processor/UidProcessor.php
+++ b/src/Monolog/Processor/UidProcessor.php
@@ -1,4 +1,4 @@
-<?php
+<?php declare(strict_types=1);
/*
* This file is part of the Monolog package.
@@ -20,16 +20,16 @@ class UidProcessor
{
private $uid;
- public function __construct($length = 7)
+ public function __construct(int $length = 7)
{
if (!is_int($length) || $length > 32 || $length < 1) {
throw new \InvalidArgumentException('The uid length must be an integer between 1 and 32');
}
- $this->uid = substr(hash('md5', uniqid('', true)), 0, $length);
+ $this->uid = substr(bin2hex(random_bytes((int) ceil($length / 2))), 0, $length);
}
- public function __invoke(array $record)
+ public function __invoke(array $record): array
{
$record['extra']['uid'] = $this->uid;
@@ -39,7 +39,7 @@ class UidProcessor
/**
* @return string
*/
- public function getUid()
+ public function getUid(): string
{
return $this->uid;
}