| Total Complexity | 5 |
| Total Lines | 58 |
| Duplicated Lines | 0 % |
| Changes | 2 | ||
| Bugs | 0 | Features | 0 |
| 1 | <?php |
||
| 22 | trait TrackableMethods |
||
| 23 | { |
||
| 24 | protected string $message; |
||
| 25 | protected iterable $context; |
||
| 26 | protected string $logLevel = LogLevel::INFO; |
||
| 27 | protected string $label = Trackable::LABEL_MISC; |
||
| 28 | |||
| 29 | /** |
||
| 30 | * A brief log message |
||
| 31 | * |
||
| 32 | * @return string |
||
| 33 | */ |
||
| 34 | public function message(): string |
||
| 35 | { |
||
| 36 | return $this->message; |
||
| 37 | } |
||
| 38 | |||
| 39 | /** |
||
| 40 | * A list of key/value pairs defining trackable context |
||
| 41 | * |
||
| 42 | * @return iterable |
||
| 43 | */ |
||
| 44 | public function context(): iterable |
||
| 45 | { |
||
| 46 | return $this->context; |
||
| 47 | } |
||
| 48 | |||
| 49 | /** |
||
| 50 | * Returns a new object with provided context |
||
| 51 | * |
||
| 52 | * @param iterable $context |
||
| 53 | * @return Trackable |
||
| 54 | */ |
||
| 55 | public function withContext(iterable $context): Trackable |
||
| 56 | { |
||
| 57 | $clone = clone $this; |
||
| 58 | $clone->context = $context; |
||
| 59 | return $clone; |
||
| 60 | } |
||
| 61 | |||
| 62 | /** |
||
| 63 | * Trackable log level |
||
| 64 | * |
||
| 65 | * @return string |
||
| 66 | */ |
||
| 67 | public function logLevel(): string |
||
| 68 | { |
||
| 69 | return $this->logLevel; |
||
| 70 | } |
||
| 71 | |||
| 72 | /** |
||
| 73 | * type |
||
| 74 | * |
||
| 75 | * @return string |
||
| 76 | */ |
||
| 77 | public function label(): string |
||
| 80 | } |
||
| 81 | } |
||
| 82 |