Completed
Push — master ( bae3ba...8110a3 )
by Morris
28:41 queued 14:22
created

FileName::executeStringCheck()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 7

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
nc 2
nop 3
dl 0
loc 7
rs 10
c 0
b 0
f 0
1
<?php
2
declare(strict_types=1);
3
/**
4
 * @copyright Copyright (c) 2018 Daniel Kesselberg <[email protected]>
5
 *
6
 * @license GNU AGPL version 3 or any later version
7
 *
8
 * This program is free software: you can redistribute it and/or modify
9
 * it under the terms of the GNU Affero General Public License as
10
 * published by the Free Software Foundation, either version 3 of the
11
 * License, or (at your option) any later version.
12
 *
13
 * This program is distributed in the hope that it will be useful,
14
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16
 * GNU Affero General Public License for more details.
17
 *
18
 * You should have received a copy of the GNU Affero General Public License
19
 * along with this program.  If not, see <http://www.gnu.org/licenses/>.
20
 *
21
 */
22
23
namespace OCA\WorkflowEngine\Check;
24
25
use OCP\Files\Storage\IStorage;
26
use OCP\IL10N;
27
use OCP\IRequest;
28
29
class FileName extends AbstractStringCheck {
30
31
	/** @var IRequest */
32
	protected $request;
33
34
	/** @var IStorage */
35
	protected $storage;
36
37
	/** @var string */
38
	protected $path;
39
40
	/**
41
	 * @param IL10N $l
42
	 * @param IRequest $request
43
	 */
44
	public function __construct(IL10N $l, IRequest $request) {
45
		parent::__construct($l);
46
		$this->request = $request;
47
	}
48
49
	/**
50
	 * @param IStorage $storage
51
	 * @param string $path
52
	 */
53
	public function setFileInfo(IStorage $storage, $path) {
54
		$this->storage = $storage;
55
		$this->path = $path;
56
	}
57
58
	/**
59
	 * @return string
60
	 */
61
	protected function getActualValue(): string {
62
		return basename($this->path);
63
	}
64
65
	/**
66
	 * @param string $operator
67
	 * @param string $checkValue
68
	 * @param string $actualValue
69
	 * @return bool
70
	 */
71
	protected function executeStringCheck($operator, $checkValue, $actualValue): bool {
72
		if ($operator === 'is' || $operator === '!is') {
73
			$checkValue = mb_strtolower($checkValue);
74
			$actualValue = mb_strtolower($actualValue);
75
		}
76
		return parent::executeStringCheck($operator, $checkValue, $actualValue);
77
	}
78
}
79