Issues (9)

src/Model/PageView.php (1 issue)

Labels
Severity
1
<?php
2
3
/**
4
 * This file is part of slick/telemetry package
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 */
9
10
declare(strict_types=1);
11
12
namespace Slick\Telemetry\Model;
13
14
use Slick\Telemetry\Trackable;
15
16
/**
17
 * PageView
18
 *
19
 * @package Slick\Telemetry\Model
20
 */
21
final class PageView implements Trackable
22
{
23
    use TrackableMethods;
24
25
    private string $path;
26
    private float $duration;
27
28
    /**
29
     * Creates a PageView
30
     *
31
     * @param string $message
32
     * @param string $path
33
     * @param float $duration
34
     * @param iterable $context
35
     */
36
    public function __construct(string $message, string $path, float $duration = 0, iterable $context = [])
37
    {
38
        $this->message = $message;
39
        $this->path = $path;
40
        $this->duration = $duration;
41
        $this->label = Trackable::LABEL_PAGE_VIEW;
42
        $this->context = array_merge($context, [
0 ignored issues
show
It seems like $context can also be of type iterable; however, parameter $arrays of array_merge() does only seem to accept array, maybe add an additional type check? ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-type  annotation

42
        $this->context = array_merge(/** @scrutinizer ignore-type */ $context, [
Loading history...
43
            'label' => $this->label,
44
            'path' => $path,
45
            'duration' => $duration
46
        ]);
47
    }
48
49
    /**
50
     * path
51
     *
52
     * @return string
53
     */
54
    public function path(): string
55
    {
56
        return $this->path;
57
    }
58
59
    /**
60
     * duration
61
     *
62
     * @return int|null
63
     */
64
    public function duration(): float
65
    {
66
        return $this->duration;
67
    }
68
}
69