AbstractWordList   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
eloc 7
c 1
b 0
f 0
dl 0
loc 22
rs 10
wmc 3

2 Methods

Rating   Name   Duplication   Size   Complexity  
A loadData() 0 4 2
A getLine() 0 5 1
1
<?php
2
3
namespace Kaliop\eZLoremIpsumBundle\Faker\Provider;
4
5
abstract class AbstractWordList extends Base
6
{
7
    protected $data = array();
8
9
    /**
10
     * @param string $context
11
     * @return string
12
     */
13
    abstract protected function getFileName($context = '');
14
15
    protected function loadData($context = '')
16
    {
17
        if (!isset($this->data[$context])) {
18
            $this->data[$context] = file($this->getFileName($context), FILE_IGNORE_NEW_LINES | FILE_SKIP_EMPTY_LINES);
19
        }
20
    }
21
22
    protected function getLine($context = '')
23
    {
24
        $this->loadData($context);
25
        $lineNum = mt_rand(0, count($this->data[$context]) - 1);
26
        return $this->data[$context][$lineNum];
27
    }
28
}
29