Completed
Pull Request — master (#83)
by Bram Van der
02:46
created

AbstractShare   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 19
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 1

Test Coverage

Coverage 72.72%

Importance

Changes 0
Metric Value
wmc 5
lcom 1
cbo 1
dl 0
loc 19
ccs 8
cts 11
cp 0.7272
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 3 1
A setForbiddenChars() 0 3 1
A verifyPath() 0 7 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 1028
	public function __construct() {
16 1028
		$this->forbiddenCharacters = ['?', '<', '>', ':', '*', '|', '"', chr(0), "\n", "\r"];
17 1028
	}
18
19 1024
	protected function verifyPath($path) {
20 1024
		foreach ($this->forbiddenCharacters as $char) {
21 1024
			if (strpos($path, $char) !== false) {
22 692
				throw new InvalidPathException('Invalid path, "' . $char . '" is not allowed');
23
			}
24
		}
25 1024
	}
26
27
	public function setForbiddenChars(array $charList) {
28
		$this->forbiddenCharacters = $charList;
29
	}
30
}
31