Completed
Branch BUG-8511-spco-revisit-oversell... (0aad32)
by
unknown
34:42 queued 17:09
created

Locator   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 45
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 45
rs 10
wmc 4
lcom 1
cbo 1

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 10 2
A setFlags() 0 6 2
1
<?php
2
namespace EventEspresso\core\services\locators;
3
4
use Countable;
5
use  EventEspresso\core\exceptions\InvalidDataTypeException;
6
use FilesystemIterator;
7
8
if ( ! defined( 'EVENT_ESPRESSO_VERSION' ) ) {
9
	exit( 'No direct script access allowed' );
10
}
11
12
13
14
/**
15
 * Class Locator
16
 * abstract parent for classes that use SPL Iterators
17
 *
18
 * @package Event Espresso
19
 * @author  Brent Christensen
20
 * @since   4.9.0
21
 */
22
abstract class Locator implements LocatorInterface, Countable {
23
24
	/**
25
	 * @var array $flags
26
	 */
27
	protected $flags = array();
28
29
30
31
	/**
32
	 * FileLocator constructor.
33
	 *
34
	 * @access public
35
	 * @param array $flags controls how files are found and/or file data is returned
36
	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
37
	 */
38
	public function __construct( $flags = array() ) {
39
		if ( empty( $flags ) ) {
40
			$flags = array(
41
				FilesystemIterator::SKIP_DOTS,
42
				FilesystemIterator::UNIX_PATHS,
43
				FilesystemIterator::CURRENT_AS_PATHNAME
44
			);
45
		}
46
		$this->setFlags( $flags );
47
	}
48
49
50
51
	/**
52
	 * @see    http://php.net/manual/en/class.filesystemiterator.php#filesystemiterator.constants
53
	 * @access public
54
	 * @param array $flags
55
	 * @throws \EventEspresso\core\exceptions\InvalidDataTypeException
56
	 */
57
	public function setFlags( $flags ) {
58
		if ( ! is_array( $flags ) ) {
59
			throw new InvalidDataTypeException( '$flags', $flags, 'array' );
60
		}
61
		$this->flags = $flags;
62
	}
63
64
65
66
}
67
// End of file Locator.php
68
// Location: /Locator.php