Completed
Push — master ( 839455...b61e73 )
by Robin
15s
created

AbstractShare::verifyPath()   A

Complexity

Conditions 3
Paths 3

Size

Total Lines 7
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 3

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 7
ccs 6
cts 6
cp 1
rs 9.4285
cc 3
eloc 4
nc 3
nop 1
crap 3
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 1020
	public function __construct() {
16 1020
		$this->forbiddenCharacters = array('?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r");
17 1020
	}
18
19 1018
	protected function verifyPath($path) {
20 1018
		foreach ($this->forbiddenCharacters as $char) {
21 1018
			if (strpos($path, $char) !== false) {
22 342
				throw new InvalidPathException('Invalid path, "' . $char . '" is not allowed');
23
			}
24 1018
		}
25 1018
	}
26
27
	public function setForbiddenChars(array $charList) {
28
		$this->forbiddenCharacters = $charList;
29
	}
30
}
31