Completed
Pull Request — master (#8)
by
unknown
02:06
created

Configuration   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 69
Duplicated Lines 0 %

Coupling/Cohesion

Components 0
Dependencies 5

Test Coverage

Coverage 90.91%

Importance

Changes 0
Metric Value
wmc 4
lcom 0
cbo 5
dl 0
loc 69
ccs 40
cts 44
cp 0.9091
rs 10
c 0
b 0
f 0

2 Methods

Rating   Name   Duplication   Size   Complexity  
B getConfigTreeBuilder() 0 38 1
A loadConfig() 0 18 3
1
<?php
2
3
/**
4
 * This file is part of the Mediapart Selligent Client API
5
 *
6
 * CC BY-NC-SA <https://github.com/mediapart/selligent>
7
 *
8
 * For the full license information, please view the LICENSE
9
 * file that was distributed with this source code.
10
 */
11
12
namespace Mediapart\Selligent;
13
14
use Symfony\Component\Config\Definition\ConfigurationInterface;
15
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
16
use Symfony\Component\Yaml\Yaml;
17
use Symfony\Component\Config\Definition\Processor;
18
19
20
/**
21
 * Class Configuration
22
 * @package Mediapart\Selligent
23
 */
24
class Configuration implements ConfigurationInterface
25
{
26
    /**
27
     * Define configTree
28
     * @return TreeBuilder
29
     */
30 1
    public function getConfigTreeBuilder()
31
    {
32 1
        $treeBuilder = new TreeBuilder();
33 1
        $rootNode = $treeBuilder->root('selligent');
34
35
        $rootNode
36 1
          ->children()
37 1
            ->scalarNode('login')
38 1
                ->isRequired()
39 1
                ->cannotBeEmpty()
40 1
            ->end()
41 1
            ->scalarNode('password')
42 1
              ->isRequired()
43 1
              ->cannotBeEmpty()
44 1
            ->end()
45 1
            ->scalarNode('namespace')
46 1
                ->defaultValue('http://tempuri.org/')
47 1
            ->end()
48 1
            ->scalarNode('wsdl')
49 1
              ->isRequired()
50 1
              ->cannotBeEmpty()
51 1
            ->end()
52 1
            ->scalarNode('list')
53 1
                ->isRequired()
54 1
            ->end()
55 1
            ->arrayNode('options')
56 1
                ->children()
57 1
                    ->arrayNode('classmap')
58 1
                        ->isRequired()
59 1
                        ->prototype('scalar')
60 1
                    ->end()
61 1
                ->end()
62 1
            ->end()
63 1
          ->end()
64
        ;
65
66 1
        return $treeBuilder;
67
    }
68
69
    /**
70
     * load, validate and return configuration
71
     * @param string $configFile
72
     * @return array
73
     */
74 1
    public function loadConfig($configFile)
75
    {
76 1
        if (!empty($configFile)) {
77 1
            $config = Yaml::parse($configFile);
78 1
            $processor = new Processor();
79
80
            try {
81 1
                $processedConfiguration = $processor->processConfiguration(
82 1
                  new Configuration(),
83
                  $config
84 1
                );
85
86
                return $processedConfiguration;
87 1
            } catch (Exception $e) {
0 ignored issues
show
Bug introduced by
The class Mediapart\Selligent\Exception does not exist. Did you forget a USE statement, or did you not list all dependencies?

Scrutinizer analyzes your composer.json/composer.lock file if available to determine the classes, and functions that are defined by your dependencies.

It seems like the listed class was neither found in your dependencies, nor was it found in the analyzed files in your repository. If you are using some other form of dependency management, you might want to disable this analysis.

Loading history...
88
                echo $e->getMessage() . PHP_EOL;
89
            }
90
        }
91
    }
92
}
93