Handler   A
last analyzed

Complexity

Total Complexity 5

Size/Duplication

Total Lines 41
Duplicated Lines 0 %

Coupling/Cohesion

Components 2
Dependencies 0

Importance

Changes 0
Metric Value
wmc 5
lcom 2
cbo 0
dl 0
loc 41
rs 10
c 0
b 0
f 0

3 Methods

Rating   Name   Duplication   Size   Complexity  
A canHandleFile() 0 10 2
A queueFile() 0 4 1
A handleQueue() 0 7 2
1
<?php
2
3
namespace Dumkaaa\BxOptimize\Handler;
4
5
abstract class Handler implements HandlerInterface
6
{
7
    /** @var array Допустимые этим обработчиком разрешения файлов */
8
    protected $validExt = [];
9
10
    /** @var array Очередь файлов на обработку */
11
    protected $files = [];
12
13
    /**
14
     * {@inheritdoc}
15
     */
16
    public function canHandleFile($file = null)
17
    {
18
        if (is_null($file)) {
19
            throw new \Exception('В обработчик ' . get_class() . " передано неверное имя файла: $file");
20
        }
21
22
        $ext = strtolower(pathinfo($file, PATHINFO_EXTENSION));
23
24
        return in_array($ext, $this->validExt);
25
    }
26
27
    /**
28
     * {@inheritdoc}
29
     */
30
    public function queueFile($file)
31
    {
32
        $this->files[] = $file;
33
    }
34
35
    /**
36
     * {@inheritdoc}
37
     */
38
    public function handleQueue()
39
    {
40
        foreach ($this->files as $file) {
41
            echo get_class() . " обрабатывает файл: $file\n";
42
        }
43
        // TODO: Implement handleQueue() method.
44
    }
45
}
46