Passed
Push — 1.x ( 2f6c1b...f64955 )
by Ulises Jeremias
02:44
created

Countable   A

Complexity

Total Complexity 2

Size/Duplication

Total Lines 24
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
wmc 2
dl 0
loc 24
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 4 1
A count() 0 3 1
1
<?php namespace Mbh\Collection\Traits\Sequenceable\Arrayed;
2
3
/**
4
 * MBHFramework
5
 *
6
 * @link      https://github.com/MBHFramework/mbh-framework
7
 * @copyright Copyright (c) 2017 Ulises Jeremias Cornejo Fandos
8
 * @license   https://github.com/MBHFramework/mbh-framework/blob/master/LICENSE (MIT License)
9
 */
10
11
use Traversable;
12
13
trait Countable
14
{
15
    protected $sfa = null;
16
17
    /**
18
     * Create an fixed array
19
     *
20
     * @param Traversable $array data
21
     */
22
    protected function __construct(Traversable $array)
23
    {
24
        $this->sfa = $array;
25
        $this->checkCapacity();
26
    }
27
28
    /**
29
     * Countable
30
     */
31
    public function count(): int
32
    {
33
        return count($this->sfa);
34
    }
35
36
    abstract protected function checkCapacity();
37
}
38