Passed
Push — master ( 0f0c33...04715c )
by Timo
49:20 queued 18:20
created

Path::isValidSolrPath()   A

Complexity

Conditions 3
Paths 2

Size

Total Lines 10
Code Lines 5

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 5
CRAP Score 3.4746

Importance

Changes 0
Metric Value
c 0
b 0
f 0
dl 0
loc 10
ccs 5
cts 8
cp 0.625
rs 9.4285
cc 3
eloc 5
nc 2
nop 1
crap 3.4746
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 2 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 4
    public function isValidSolrPath($path)
42
    {
43 4
        $path = trim($path);
44
45 4
        if ((!empty($path)) && (preg_match('/^[^*?"<>|:#]*$/', $path))) {
46 1
            return true;
47
        }
48
49 3
        return false;
50
    }
51
}
52