Completed
Push — master ( 902d7e...ed1619 )
by Ducatel
03:03
created

StringTypedArray   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 1

Test Coverage

Coverage 100%

Importance

Changes 2
Bugs 0 Features 2
Metric Value
wmc 2
c 2
b 0
f 2
lcom 0
cbo 1
dl 0
loc 27
ccs 11
cts 11
cp 1
rs 10

1 Method

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 19 2
1
<?php
2
3
namespace Ducatel\PHPCollection\Specialized;
4
5
use Ducatel\PHPCollection\TypedArray;
6
7
/**
8
 * Class StringTypedArray
9
 * This collection is a specialization of TypedArray for string variables.
10
 * @package Ducatel\PHPCollection\Specialized
11
 */
12
class StringTypedArray extends TypedArray
13
{
14
    /**
15
     * StringTypedArray constructor.
16
     *
17
     * @param bool $caseSensitive True if the collection should be case sensitive
18
     */
19 2
    public function __construct(bool $caseSensitive = true)
20
    {
21
        $isStringFct = function ($obj) {
22 2
            return is_string($obj);
23 2
        };
24
25 2
        if ($caseSensitive) {
26
            $isEquals = function ($obj1, $obj2) {
27 1
                return (strcmp($obj1, $obj2) == 0);
28 1
            };
29
        } else {
30 1
            $isEquals = function ($obj1, $obj2) {
31 1
                return (strcasecmp($obj1, $obj2) == 0);
32 1
            };
33
        }
34
35
36 2
        parent::__construct($isStringFct, $isEquals);
37 2
    }
38
}
39