LoggingProfiler::setMangan()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 0
Metric Value
dl 0
loc 5
ccs 0
cts 5
cp 0
rs 10
c 0
b 0
f 0
cc 1
nc 1
nop 1
crap 2
1
<?php
2
3
/**
4
 * This software package is licensed under AGPL or Commercial license.
5
 *
6
 * @package maslosoft/mangan
7
 * @licence AGPL or Commercial
8
 * @copyright Copyright (c) Piotr Masełkowski <[email protected]>
9
 * @copyright Copyright (c) Maslosoft
10
 * @copyright Copyright (c) Others as mentioned in code
11
 * @link https://maslosoft.com/mangan/
12
 */
13
14
namespace Maslosoft\Mangan\Profillers;
15
16
use Maslosoft\Mangan\Interfaces\ManganAwareInterface;
17
use Maslosoft\Mangan\Interfaces\ProfilerInterface;
18
use Maslosoft\Mangan\Mangan;
19
use MongoCursor;
20
21
/**
22
 * Profiller
23
 *
24
 * @author Piotr Maselkowski <pmaselkowski at gmail.com>
25
 */
26
class LoggingProfiler implements ProfilerInterface, ManganAwareInterface
27
{
28
29
	/**
30
	 * Mangan instance
31
	 * @var Mangan
32
	 */
33
	private $mangan = null;
34
35
	/**
36
	 * Proifile any data
37
	 * @param string $data
38
	 */
39
	public function profile($data)
40
	{
41
		$this->mangan->getLogger()->info($data);
42
	}
43
44
	/**
45
	 * Profile cursor
46
	 * @param MongoCursor $cursor
47
	 */
48
	public function cursor($cursor)
49
	{
50
		$this->mangan->getLogger()->info(var_export($cursor->explain(), true));
51
	}
52
53
	/**
54
	 * Set mangan instance
55
	 * @param Mangan $mangan
56
	 * @return LoggingProfiler
57
	 */
58
	public function setMangan(Mangan $mangan)
59
	{
60
		$this->mangan = $mangan;
61
		return $this;
62
	}
63
64
}
65