MediaParser   A
last analyzed

Complexity

Total Complexity 6

Size/Duplication

Total Lines 37
Duplicated Lines 0 %

Coupling/Cohesion

Components 1
Dependencies 2

Importance

Changes 1
Bugs 0 Features 0
Metric Value
wmc 6
c 1
b 0
f 0
lcom 1
cbo 2
dl 0
loc 37
rs 10

2 Methods

Rating   Name   Duplication   Size   Complexity  
A __construct() 0 8 2
A FindMedia() 0 17 4
1
<?php
2
3
/*
4
 * This file is part of the Assets Finder Package
5
 *
6
 * (c) Nexuslink Services
7
 *
8
 * For the full copyright and license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace AssetsFinder;
13
14
use Symfony\Component\Yaml\Yaml;
15
use AssetsFinder\src\Services\MediaAssetsFinder;
16
17
class MediaParser {
18
19
    private $pathToYml;
20
21
    public function __construct($pathToYml = '') {
22
23
        if (!empty($pathToYml)) {
24
            $this->pathToYml = $pathToYml;
25
        } else {
26
            $this->pathToYml = __DIR__."/../Resources/config/config.yml";
27
        }
28
    }
29
30
    /**
31
     * @param string $content
32
     * 
33
     * @return string
34
     */
35
    public function FindMedia($content) {
36
        
37
        $configArray = Yaml::parse(file_get_contents($this->pathToYml));
38
        $mediaList = array();
39
40
        if ($configArray['media_options']['mp3']) {
41
            $mediaList['mp3'] = MediaAssetsFinder::assetsFilter($content, 'mp3');
42
        }
43
        if ($configArray['media_options']['mp4']) {
44
            $mediaList['mp4'] = MediaAssetsFinder::assetsFilter($content, 'mp4');
45
        }
46
        if ($configArray['media_options']['jpg']) {
47
            $mediaList['jpg'] = MediaAssetsFinder::assetsFilter($content, 'jpg');
48
        }
49
        
50
        return $mediaList;
51
    }
52
    
53
}
54