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.
Passed
Pull Request — master (#49)
by
unknown
02:09
created

CrudTemplateExtension::humanize_uc()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 2
CRAP Score 1

Importance

Changes 0
Metric Value
dl 0
loc 4
ccs 2
cts 2
cp 1
rs 10
c 0
b 0
f 0
cc 1
eloc 2
nc 1
nop 1
crap 1
1
<?php
2
3
namespace Petkopara\CrudGeneratorBundle\Twig;
4
5
/**
6
 * Class CrudTemplateExtension
7
 * @package PetkoparaCrudGeneratorBundle\Twig
8
 *
9
 * This class adds two Twig filters: "humanize_lc" and "humanize_uc". Both of them
10
 * split camelCase and snake_case strings on their uppercase letters and "_" character,
11
 * respectively, to form a more human readable sentence.
12
 *
13
 * The _lc variant returns all words in the sentence in lower case. The _uc variant
14
 * makes all words in the sentence lowercase, except the first word which has its
15
 * first letter uppercase.
16
 *
17
 */
18
class CrudTemplateExtension extends \Twig_Extension
19
{
20
21 2
    public function getFilters()
22
    {
23
        return array(
24 2
            new \Twig_SimpleFilter('humanize_lc', array($this, 'humanize_lc')),
25 2
            new \Twig_SimpleFilter('humanize_uc', array($this, 'humanize_uc'))
26 2
        );
27
    }
28
29
    /**
30
     * Splits the incoming $text string on all uppercase letters and "_" characters,
31
     * and returns the resulting words as a sentence. All words in the output sentence
32
     * are lowercase.
33
     *
34
     * @param string $text
35
     * @return string
36
     */
37 6
    public function humanize_lc($text)
38
    {
39 6
        return strtolower(trim(preg_replace(array('/([A-Z])/', '/[_\s]+/'), array('_$1', ' '), $text)));
40
    }
41
42
    /**
43
     * Splits the incoming $text string on all uppercase letters and "_" characters,
44
     * and returns the resulting words as a sentence. The first character of the first
45
     * word is set to uppercase, all other letters are set to lowercase.
46
     *
47
     * @param string $text
48
     * @return string
49
     */
50 6
    public function humanize_uc($text)
51
    {
52 6
        return ucfirst($this->humanize_lc($text));
53
    }
54
55
}