GitHub Access Token became invalid

It seems like the GitHub access token used for retrieving details about this repository from GitHub became invalid. This might prevent certain types of inspections from being run (in particular, everything related to pull requests).
Please ask an admin of your repository to re-new the access token on this website.
Completed
Pull Request — master (#158)
by Bernardo Vieira da
12:24
created

UniqueJobIdentifierGenerator::generateUniqueKey()   A

Complexity

Conditions 4
Paths 8

Size

Total Lines 13

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 6
CRAP Score 4.0466

Importance

Changes 0
Metric Value
dl 0
loc 13
ccs 6
cts 7
cp 0.8571
rs 9.8333
c 0
b 0
f 0
cc 4
nc 8
nop 4
crap 4.0466
1
<?php
2
3
/**
4
 * Gearman Bundle for Symfony2
5
 *
6
 * For the full copyright and license information, please view the LICENSE
7
 * file that was distributed with this source code.
8
 *
9
 * Feel free to edit as you please, and have fun.
10
 *
11
 * @author Marc Morera <[email protected]>
12
 */
13
14
namespace Mmoreram\GearmanBundle\Generator;
15
16
use Mmoreram\GearmanBundle\Exceptions\WorkerNameTooLongException;
17
18
/**
19
 * Job Unique Key generator
20
 *
21
 * @see https://github.com/mmoreram/GearmanBundle/issues/66
22
 *
23
 * @since 2.3.1
24
 */
25
class UniqueJobIdentifierGenerator
26
{
27
    /**
28
     * @var string
29
     *
30
     * Generate unique key
31
     */
32
    protected $generateUniqueKey;
33
34
    /**
35
     * Construct method
36
     *
37
     * @param string $generateUniqueKey Generate unique key
38
     */
39 4
    public function __construct($generateUniqueKey)
40
    {
41 4
        $this->generateUniqueKey = $generateUniqueKey;
42 4
    }
43
44
    /**
45
     * Generate unique key if generateUniqueKey is enabled
46
     *
47
     * Even some parameters are not used, are passed to allow user overwrite
48
     * method
49
     *
50
     * Also, if name and unique value exceeds 114 bytes, an exception is thrown
51
     *
52
     * @param string $name   A GermanBundle registered function to be executed
53
     * @param string $params Parameters to send to task as string
54
     * @param string $unique unique ID used to identify a particular task
55
     * @param string $method Method to perform
56
     *
57
     * @return string Generated Unique Key
58
     *
59
     * @throws WorkerNameTooLongException If name is too large
60
     *
61
     * @api
62
     */
63 2
    public function generateUniqueKey($name, $params, $unique, $method)
0 ignored issues
show
Unused Code introduced by
The parameter $method is not used and could be removed.

This check looks from parameters that have been defined for a function or method, but which are not used in the method body.

Loading history...
64
    {
65 2
        $unique = !$unique && $this->generateUniqueKey
66 1
            ? md5($name . $params)
67 2
            : $unique;
68
69 2
        if (strlen($name . $unique) > 114) {
70
71
            throw new WorkerNameTooLongException;
72
        }
73
74 2
        return $unique;
75
    }
76
}
77