Completed
Pull Request — master (#73)
by rxu
01:18
created

cache   A

Complexity

Total Complexity 3

Size/Duplication

Total Lines 33
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 0

Importance

Changes 0
Metric Value
wmc 3
lcom 1
cbo 0
dl 0
loc 33
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A purge() 0 13 2
1
<?php
2
/**
3
 *
4
 * phpBB Media Embed PlugIn extension for the phpBB Forum Software package.
5
 *
6
 * @copyright (c) 2020 phpBB Limited <https://www.phpbb.com>
7
 * @license GNU General Public License, version 2 (GPL-2.0)
8
 *
9
 */
10
11
namespace phpbb\mediaembed\cache;
12
13
use \Symfony\Component\Finder\Finder;
14
15
/**
16
 * Media Embed cache handling class.
17
 */
18
class cache
19
{
20
	/** @var \phpbb\cache\driver\driver_interface */
21
	protected $cache;
22
23
	/**
24
	 * Constructor
25
	 *
26
	 * @param \phpbb\cache\driver\driver_interface  $cache   Cache driver object
27
	 * @access public
28
	 */
29
	public function __construct(\phpbb\cache\driver\driver_interface $cache)
30
	{
31
		$this->cache = $cache;
32
	}
33
34
	/**
35
	 * Purge all MediaEmbed cache files
36
	 */
37
	public function purge()
38
	{
39
		$finder = new Finder();
40
		$finder
41
			->name('http.*')
42
			->in($this->cache->cache_dir)
43
			->files();
44
45
		foreach ($finder as $file)
46
		{
47
			$this->cache->remove_file($file->getRealPath());
48
		}
49
	}
50
}
51