Completed
Push — master ( 1c0463...6ee2a7 )
by Rafael
34:09
created

HierarchyTool   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 0

Importance

Changes 0
Metric Value
wmc 2
lcom 0
cbo 0
dl 0
loc 25
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A substituteSlashes() 0 4 1
A unSubstituteSlashes() 0 4 1
1
<?php
2
namespace ApacheSolrForTypo3\Solr\Domain\Search\ResultSet\Facets\OptionBased\Hierarchy;
3
4
/*
5
 * This file is part of the TYPO3 CMS project.
6
 *
7
 * It is free software; you can redistribute it and/or modify it under
8
 * the terms of the GNU General Public License, either version 2
9
 * of the License, or any later version.
10
 *
11
 * For the full copyright and license information, please read the
12
 * LICENSE.txt file that was distributed with this source code.
13
 *
14
 * The TYPO3 project - inspiring people to share!
15
*/
16
17
class HierarchyTool
18
{
19
    /**
20
     * Replaces all escaped slashes in a hierarchy path with @@@slash@@@ to afterwards
21
     * only have slashes in the content that are real path separators.
22
     *
23
     * @param string $pathWithContentSlashes
24
     * @return string
25
     */
26
    public static function substituteSlashes(string $pathWithContentSlashes): string
27
    {
28
        return  (string)str_replace('\/', '@@@slash@@@', $pathWithContentSlashes);
29
    }
30
31
    /**
32
     * Replaces @@@slash@@@ with \/ to have the path usable for solr again.
33
     *
34
     * @param string $pathWithReplacedContentSlashes
35
     * @return string
36
     */
37
    public static function unSubstituteSlashes(string $pathWithReplacedContentSlashes): string
38
    {
39
        return (string)str_replace('@@@slash@@@', '\/', $pathWithReplacedContentSlashes);
40
    }
41
}