AlreadyExtractFactory   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 23
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 2

Importance

Changes 0
Metric Value
wmc 3
lcom 0
cbo 2
dl 0
loc 23
rs 10
c 0
b 0
f 0

1 Method

Rating   Name   Duplication   Size   Complexity  
A create() 0 11 3
1
<?php
2
3
namespace AlreadyExtract\Factory;
4
5
use AlreadyExtract\Checker\AlreadyExtractCheckerInterface;
6
use AlreadyExtract\Checker\RarAlreadyExtractChecker;
7
use AlreadyExtract\Checker\ZipAlreadyExtractChecker;
8
9
class AlreadyExtractFactory
10
{
11
    const ZIP = 'zip';
12
    const RAR = 'rar';
13
14
    /**
15
     * @param $path
16
     * @param $type
17
     * @return AlreadyExtractCheckerInterface
18
     * @throws \Exception
19
     */
20
    public static function create($path, $type)
21
    {
22
        switch ($type) {
23
            case self::ZIP:
24
                return new ZipAlreadyExtractChecker($path);
25
            case self::RAR:
26
                return new RarAlreadyExtractChecker($path);
27
            default:
28
                throw new \Exception('Unknown archive type');
29
        }
30
    }
31
}