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.

StringHelper::convertToCamelCase()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 5
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Importance

Changes 2
Bugs 1 Features 0
Metric Value
c 2
b 1
f 0
dl 0
loc 5
rs 9.4285
cc 2
eloc 3
nc 2
nop 2
1
<?php
2
/**
3
 * String helper
4
 *
5
 * @author Kachit
6
 * @package Kachit\Helper
7
 */
8
namespace Kachit\Helper;
9
10
class StringHelper
11
{
12
    /**
13
     * Convert string to camelCase
14
     *
15
     * @param string $string
16
     * @param bool $lcfirst
17
     * @return string
18
     */
19
    public function convertToCamelCase($string, $lcfirst = true)
20
    {
21
        $string = str_replace(' ', '', ucwords(strtolower(preg_replace('/[-_]/', ' ', $string))));
22
        return ($lcfirst) ? lcfirst($string) : $string;
23
    }
24
25
    /**
26
     * Convert string to under_score
27
     *
28
     * @param string $word
29
     * @return string
30
     */
31
    public function convertToUnderscore($word)
32
    {
33
        $word = trim($word);
34
        $word = preg_replace('/[^a-zA-Z0-9\-\_\s]/', '', $word);
35
        $word = preg_replace('/[\_\s\-]+/', '_', $word);
36
        $word = preg_replace('/([a-z])([A-Z])/', '\\1_\\2', $word);
37
        $word = strtolower($word);
38
        return $word;
39
    }
40
41
    /**
42
     * limitWords
43
     *
44
     * @param string $text
45
     * @param int $limitWords
46
     * @param string $suffix
47
     * @return string
48
     */
49
    public function limitWords($text, $limitWords = 50, $suffix = '...')
50
    {
51
        $textArray = explode(' ', $text);
52
        $count = count($textArray);
53
        if ($count > $limitWords) {
54
            $result = array_slice($textArray, 0, $limitWords);
55
            $text = implode(' ', $result) . $suffix;
56
        }
57
        return $text;
58
    }
59
}