HelperFunctions::java_truncate()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 7
Code Lines 3

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 4
CRAP Score 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
cc 2
eloc 3
c 1
b 0
f 0
nc 2
nop 1
dl 0
loc 7
ccs 4
cts 4
cp 1
crap 2
rs 10
1
<?php
2
3
declare(strict_types=1);
4
5
namespace Soluble\Japha\Bridge\Driver\Pjb62\Utils;
6
7
/**
8
 * @author Vanvelthem Sébastien
9
 */
10
class HelperFunctions
11
{
12
    /**
13
     * @return int
14
     */
15 2
    public static function java_get_session_lifetime(): int
16
    {
17 2
        $session_max_lifetime = ini_get('session.gc_maxlifetime');
18
19 2
        return $session_max_lifetime ? (int) $session_max_lifetime : 1440;
20
    }
21
22
    /**
23
     * @param string $str
24
     *
25
     * @return string
26
     */
27 1
    public static function java_truncate(string $str): string
28
    {
29 1
        if (strlen($str) > 955) {
30 1
            return substr($str, 0, 475).'[...]'.substr($str, -475);
31
        }
32
33 1
        return $str;
34
    }
35
}
36