-
Notifications
You must be signed in to change notification settings - Fork 23
Expand file tree
/
Copy pathXCache.php
More file actions
64 lines (55 loc) · 1.43 KB
/
XCache.php
File metadata and controls
64 lines (55 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
<?php
/**
* XCache Code Coverage Driver
*
* @copyright 2013 Anthon Pang
*
* @license BSD-3-Clause
*/
namespace LeanPHP\Behat\CodeCoverage\Common\Driver;
use SebastianBergmann\CodeCoverage\Driver\Driver as DriverInterface;
/**
* XCache Driver
*
* {@internal Derived from SebastianBergmann\CodeCoverage\Driver\Xdebug.}
*
* @author Anthon Pang <apang@softwaredevelopment.ca>
*/
class XCache implements DriverInterface
{
/**
* Constructor
*
* @throws \SebastianBergmann\CodeCoverage\RuntimeException if PHP code coverage not enabled
*/
public function __construct()
{
if (! extension_loaded('xcache')) {
throw new \SebastianBergmann\CodeCoverage\RuntimeException('This driver requires XCache');
}
if (version_compare(phpversion('xcache'), '1.2.0', '<') ||
! ini_get('xcache.coverager')
) {
throw new \SebastianBergmann\CodeCoverage\RuntimeException('xcache.coverager=On has to be set in php.ini');
}
}
/**
* {@inheritdoc}
*/
public function start(bool $determineUnusedAndDead = true): void
{
xcache_coverager_start();
}
/**
* {@inheritdoc}
*/
public function stop(): array
{
$codeCoverage = xcache_coverager_get();
if (null === $codeCoverage) {
$codeCoverage = [];
}
xcache_coverager_stop(true);
return $codeCoverage;
}
}