Failed Conditions
Pull Request — master (#3000)
by
unknown
37:55
created

Path::isValidSolrPath()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 9
Code Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3

Importance

Changes 0
Metric Value
eloc 4
c 0
b 0
f 0
dl 0
loc 9
ccs 5
cts 5
cp 1
rs 10
cc 3
nc 2
nop 1
crap 3
1
<?php
2
namespace ApacheSolrForTypo3\Solr\System\Validator;
3
4
/***************************************************************
5
 *  Copyright notice
6
 *
7
 *  (c) 2017 - Thomas Hohn <[email protected]>
8
 *  All rights reserved
9
 *
10
 *  This script is part of the TYPO3 project. The TYPO3 project is
11
 *  free software; you can redistribute it and/or modify
12
 *  it under the terms of the GNU General Public License as published by
13
 *  the Free Software Foundation; either version 3 of the License, or
14
 *  (at your option) any later version.
15
 *
16
 *  The GNU General Public License can be found at
17
 *  http://www.gnu.org/copyleft/gpl.html.
18
 *
19
 *  This script is distributed in the hope that it will be useful,
20
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
21
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
22
 *  GNU General Public License for more details.
23
 *
24
 *  This copyright notice MUST APPEAR in all copies of the script!
25
 ***************************************************************/
26
27
/**
28
 * Class Path is used for Solr Path related methods
29
 *
30
 * @author Thomas Hohn <[email protected]>
31
 */
32
class Path
33
{
34
35
    /**
36
     * Validate that a path is a valid Solr Path
37
     *
38
     * @param string $path
39
     * @return bool
40
     */
41 8
    public function isValidSolrPath($path)
42
    {
43 8
        $path = trim($path);
44
45 8
        if ((!empty($path)) && (preg_match('/^[^*?"<>|:#]*$/', $path))) {
46 2
            return true;
47
        }
48
49 6
        return false;
50
    }
51
}
52