Exemple #1
0
 /**
  * Get the tree used for the application
  *
  * @return \Symfony\Component\Config\Definition\NodeInterface
  */
 public function getTree()
 {
     $treeBuilder = new \Symfony\Component\Config\Definition\Builder\TreeBuilder();
     $rootNode = $treeBuilder->root('phpmetrics');
     $rootNode->children()->arrayNode('rules')->useAttributeAsKey('rulename')->prototype('array')->children()->scalarNode('0')->end()->scalarNode('1')->end()->scalarNode('2')->end()->end()->end()->end()->scalarNode('failure')->defaultValue(null)->end()->arrayNode('path')->addDefaultsIfNotSet()->children()->scalarNode('directory')->defaultValue(null)->end()->scalarNode('exclude')->defaultValue('Tests|tests|Features|features|\\.svn|\\.git|vendor')->end()->scalarNode('extensions')->defaultValue('php|inc')->end()->booleanNode('symlinks')->defaultValue(false)->end()->end()->end()->booleanNode('ignore-errors')->defaultValue(false)->end()->arrayNode('logging')->addDefaultsIfNotSet()->children()->arrayNode('report')->children()->scalarNode('html')->defaultValue(null)->end()->scalarNode('xml')->defaultValue(null)->end()->scalarNode('csv')->defaultValue(null)->end()->scalarNode('json')->defaultValue(null)->end()->scalarNode('cli')->defaultValue(null)->end()->end()->end()->arrayNode('violations')->children()->scalarNode('xml')->defaultValue(null)->end()->end()->end()->arrayNode('chart')->children()->scalarNode('bubbles')->defaultValue(null)->end()->end()->end()->end()->end()->arrayNode('template')->addDefaultsIfNotSet()->children()->scalarNode('title')->defaultValue('PhpMetrics report')->end()->end()->end();
     return $treeBuilder->buildTree();
 }
Exemple #2
0
 /**
  * @param array $config
  */
 function process(array $config)
 {
     $treeBuilder = new \Symfony\Component\Config\Definition\Builder\TreeBuilder();
     $rootNode = $treeBuilder->root('root', 'array');
     $root = $rootNode->children();
     $mail = $root->arrayNode('mail')->canBeEnabled()->addDefaultsIfNotSet()->children();
     $mail->scalarNode('to')->cannotBeEmpty()->isRequired()->end();
     $mail->scalarNode('subject')->cannotBeEmpty()->isRequired()->end();
     $mail->scalarNode('from')->cannotBeEmpty()->isRequired()->end();
     $processor = new \Symfony\Component\Config\Definition\Processor();
     return $processor->process($treeBuilder->buildTree(), ['root' => $config]);
 }