Naming   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 34
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Importance

Changes 1
Bugs 0 Features 1
Metric Value
wmc 2
c 1
b 0
f 1
lcom 0
cbo 1
dl 0
loc 34
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A getProjectName() 0 7 1
A getUniqueKey() 0 8 1
1
<?php
2
3
namespace Joli\JoliCi;
4
5
use Behat\Transliterator\Transliterator;
6
7
class Naming
8
{
9
    /**
10
     * Return a translitared name for a project
11
     *
12
     * @param string $projectPath Project directory
13
     *
14
     * @return string
15
     */
16
    public function getProjectName($projectPath)
17
    {
18
        $project = basename(realpath($projectPath));
19
        $project = Transliterator::transliterate($project, '-');
20
21
        return $project;
22
    }
23
24
    /**
25
     * Generate a unique key for a list of parameters, with same parameters
26
     * the key must not change (no random stuff) and the order does not matter
27
     *
28
     * @param array $parameters
29
     *
30
     * @return integer
31
     */
32
    public function getUniqueKey($parameters = array())
33
    {
34
        // First ordering parameters
35
        ksort($parameters);
36
37
        // Return a hash of the serialzed parameters
38
        return crc32(serialize($parameters));
39
    }
40
}
41