Mark::__get()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 3
rs 10
cc 1
eloc 2
nc 1
nop 1
1
<?php
2
/*
3
 * This file is part of Yolk - Gamer Network's PHP Framework.
4
 *
5
 * Copyright (c) 2014 Gamer Network Ltd.
6
 * 
7
 * Distributed under the MIT License, a copy of which is available in the
8
 * LICENSE file that was bundled with this package, or online at:
9
 * https://github.com/gamernetwork/yolk-profiler
10
 */
11
12
namespace yolk\profiler;
13
14
/**
15
 * A point-in-time mark to record elapsed time and memory usage.
16
 * @property-read string $name name of the mark
17
 * @property-read float  $elapsed elapsed time
18
 * @property-read float  $memory memory usage
19
 * @property-read float  $time_diff elapsed time since previous mark
20
 * @property-read float  $memory_diff memory usage since previous mark
21
 */
22
class Mark {
23
24
	protected $name;
25
	protected $elapsed;
26
	protected $memory;
27
	protected $time_diff;
28
	protected $memory_diff;
29
30
	public function __construct( $name, $elapsed, $memory, $time_diff, $mem_diff ) {
31
		$this->name         = $name;
32
		$this->elapsed      = $elapsed;
33
		$this->memory       = $memory;
34
		$this->time_diff    = $time_diff;
35
		$this->memory_diff  = $mem_diff;
36
	}
37
38
	public function __get( $key ) {
39
		return $this->$key;
40
	}
41
42
	public function __isset( $key ) {
43
		return isset($this->$key);
44
	}
45
46
	public function toArray() {
47
		return [
48
			'name'        => $this->name,
49
			'elapsed'     => $this->elapsed,
50
			'memory'      => $this->memory,
51
			'time_diff'   => $this->time_diff,
52
			'memory_diff' => $this->memory_diff,
53
		];
54
	}
55
56
}
57
58
// EOF