Passed
Pull Request — release-11.5.x (#3206)
by Michael
40:59 queued 01:38
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
3
/*
4
 * This file is part of the TYPO3 CMS project.
5
 *
6
 * It is free software; you can redistribute it and/or modify it under
7
 * the terms of the GNU General Public License, either version 2
8
 * of the License, or any later version.
9
 *
10
 * For the full copyright and license information, please read the
11
 * LICENSE.txt file that was distributed with this source code.
12
 *
13
 * The TYPO3 project - inspiring people to share!
14
 */
15
16
namespace ApacheSolrForTypo3\Solr\System\Validator;
17
18
/**
19
 * Class Path is used for Solr Path related methods
20
 *
21
 * @author Thomas Hohn <[email protected]>
22
 */
23
class Path
24
{
25
26
    /**
27
     * Validate that a path is a valid Solr Path
28
     *
29
     * @param string $path
30
     * @return bool
31
     */
32 4
    public function isValidSolrPath($path)
33
    {
34 4
        $path = trim($path);
35
36 4
        if ((!empty($path)) && (preg_match('/^[^*?"<>|:#]*$/', $path))) {
37 1
            return true;
38
        }
39
40 3
        return false;
41
    }
42
}
43