MediaParser::FindMedia()   A
last analyzed

Complexity

Conditions 4
Paths 8

Size

Total Lines 17
Code Lines 10

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 0
Metric Value
c 1
b 0
f 0
dl 0
loc 17
rs 9.2
cc 4
eloc 10
nc 8
nop 1
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