slickframework /
telemetry
| 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
Bug
introduced
by
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 |