Passed
Push — master ( 742be8...9fb175 )
by Robin
04:11
created

AbstractShare   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 17
Duplicated Lines 0 %

Test Coverage

Coverage 80%

Importance

Changes 2
Bugs 0 Features 0
Metric Value
eloc 7
dl 0
loc 17
ccs 8
cts 10
cp 0.8
rs 10
c 2
b 0
f 0
wmc 5

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 2 1
A verifyPath() 0 4 3
A setForbiddenChars() 0 2 1
1
<?php
2
/**
3
 * Copyright (c) 2015 Robin Appelman <[email protected]>
4
 * This file is licensed under the Licensed under the MIT license:
5
 * http://opensource.org/licenses/MIT
6
 */
7
8
namespace Icewind\SMB;
9
10
use Icewind\SMB\Exception\InvalidPathException;
11
12
abstract class AbstractShare implements IShare {
13
	private $forbiddenCharacters;
14
15 1016
	public function __construct() {
16 1016
		$this->forbiddenCharacters = ['?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"];
17 1016
	}
18
19 1016
	protected function verifyPath($path) {
20 1016
		foreach ($this->forbiddenCharacters as $char) {
21 1016
			if (strpos($path, $char) !== false) {
22 679
				throw new InvalidPathException('Invalid path, "' . $char . '" is not allowed');
23
			}
24
		}
25 1016
	}
26
27
	public function setForbiddenChars(array $charList) {
28
		$this->forbiddenCharacters = $charList;
29
	}
30
}
31