turnaev /
monitor-bundle
| 1 | <?php |
||||
| 2 | |||||
| 3 | /** |
||||
| 4 | * This file is part of the `tvi/monitor-bundle` project. |
||||
| 5 | * |
||||
| 6 | * (c) https://github.com/turnaev/monitor-bundle/graphs/contributors |
||||
| 7 | * |
||||
| 8 | * For the full copyright and license information, please view the LICENSE.md |
||||
| 9 | * file that was distributed with this source code. |
||||
| 10 | */ |
||||
|
0 ignored issues
–
show
Coding Style
introduced
by
Loading history...
|
|||||
| 11 | |||||
| 12 | namespace Tvi\MonitorBundle\Check; |
||||
| 13 | |||||
| 14 | use Symfony\Component\Config\Definition\Builder\ArrayNodeDefinition; |
||||
| 15 | use Symfony\Component\Config\Definition\Builder\TreeBuilder; |
||||
| 16 | use Tvi\MonitorBundle\Exception\FeatureRequired; |
||||
| 17 | |||||
| 18 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 19 | * @author Vladimir Turnaev <[email protected]> |
||||
| 20 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 21 | abstract class CheckPluginAbstract implements CheckPluginInterface |
||||
| 22 | { |
||||
| 23 | /** |
||||
|
0 ignored issues
–
show
|
|||||
| 24 | * @throws FeatureRequired |
||||
| 25 | */ |
||||
|
0 ignored issues
–
show
|
|||||
| 26 | 35 | public function checkRequirements(array $checkSettings) |
|||
| 27 | { |
||||
| 28 | 35 | } |
|||
| 29 | |||||
| 30 | 57 | public function checkConf(TreeBuilder $builder): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 31 | { |
||||
| 32 | $node = $builder |
||||
| 33 | 57 | ->root(static::CHECK_NAME, 'array') |
|||
| 34 | 57 | ->info(static::DESCR); //-- |
|||
| 35 | |||||
| 36 | 57 | $this->_check($node); |
|||
| 37 | |||||
| 38 | 57 | return $node; |
|||
|
0 ignored issues
–
show
|
|||||
| 39 | } |
||||
| 40 | |||||
| 41 | 57 | public function checkFactoryConf(TreeBuilder $builder): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 42 | { |
||||
| 43 | $node = $builder |
||||
| 44 | 57 | ->root(static::CHECK_NAME.'_factory', 'array') |
|||
| 45 | 57 | ->info(static::DESCR) |
|||
| 46 | 57 | ->children() |
|||
| 47 | 57 | ->arrayNode('items') |
|||
|
0 ignored issues
–
show
|
|||||
| 48 | 57 | ->prototype('array'); //-- |
|||
|
0 ignored issues
–
show
|
|||||
| 49 | 57 | $node = $this->_check($node) |
|||
| 50 | 57 | ->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 51 | 57 | ->end() |
|||
|
0 ignored issues
–
show
The method
end() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of said class. However, the method does not exist in Symfony\Component\Config...ion\Builder\TreeBuilder. Are you sure you never get one of those?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 52 | 57 | ->end(); |
|||
| 53 | |||||
| 54 | 57 | $this->_addition($node); |
|||
| 55 | |||||
| 56 | 57 | return $node; |
|||
| 57 | } |
||||
| 58 | |||||
| 59 | 57 | protected function _addition(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 60 | { |
||||
| 61 | 57 | $this->_group($node); |
|||
| 62 | 57 | $this->_tags($node); |
|||
| 63 | 57 | $this->_importance($node); |
|||
| 64 | 57 | $this->_label($node); |
|||
| 65 | 57 | $this->_descr($node); |
|||
| 66 | |||||
| 67 | 57 | return $node; |
|||
| 68 | } |
||||
| 69 | |||||
| 70 | abstract protected function _check(ArrayNodeDefinition $node): ArrayNodeDefinition; |
||||
|
0 ignored issues
–
show
|
|||||
| 71 | |||||
| 72 | 57 | protected function _label(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 73 | { |
||||
| 74 | return $node |
||||
| 75 | 57 | ->children() |
|||
| 76 | 57 | ->scalarNode('label')->defaultNull()->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 77 | 57 | ->end(); |
|||
| 78 | } |
||||
| 79 | |||||
| 80 | 57 | protected function _importance(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 81 | { |
||||
| 82 | return $node |
||||
| 83 | 57 | ->children() |
|||
| 84 | 57 | ->scalarNode('importance') |
|||
|
0 ignored issues
–
show
|
|||||
| 85 | 57 | ->validate() |
|||
|
0 ignored issues
–
show
|
|||||
| 86 | 57 | ->ifTrue(static function ($value) { |
|||
|
0 ignored issues
–
show
|
|||||
| 87 | 1 | if (null === $value) { |
|||
| 88 | return false; |
||||
| 89 | 1 | } elseif (\in_array($value, CheckAbstract::getImportances(), true)) { |
|||
| 90 | 1 | return false; |
|||
| 91 | } |
||||
| 92 | |||||
| 93 | return true; |
||||
| 94 | 57 | }) |
|||
|
0 ignored issues
–
show
For multi-line function calls, the closing parenthesis should be on a new line.
If a function call spawns multiple lines, the coding standard suggests to move the closing parenthesis to a new line: someFunctionCall(
$firstArgument,
$secondArgument,
$thirdArgument
); // Closing parenthesis on a new line.
Loading history...
|
|||||
| 95 | 57 | ->thenInvalid(sprintf('importance has to one of value [%s]', implode(', ', CheckAbstract::getImportances()))) |
|||
| 96 | 57 | ->end() |
|||
| 97 | 57 | ->defaultNull() |
|||
| 98 | 57 | ->end() |
|||
| 99 | 57 | ->end(); |
|||
| 100 | } |
||||
| 101 | |||||
| 102 | 57 | protected function _group(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 103 | { |
||||
| 104 | return $node |
||||
| 105 | 57 | ->children() |
|||
| 106 | 57 | ->scalarNode('group') |
|||
|
0 ignored issues
–
show
|
|||||
| 107 | 57 | ->cannotBeEmpty() |
|||
|
0 ignored issues
–
show
|
|||||
| 108 | 57 | ->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 109 | 57 | ->scalarNode('_group') |
|||
|
0 ignored issues
–
show
The method
scalarNode() does not exist on Symfony\Component\Config...der\NodeParentInterface. It seems like you code against a sub-type of Symfony\Component\Config...der\NodeParentInterface such as Symfony\Component\Config...ion\Builder\NodeBuilder.
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 110 | 57 | ->defaultValue(static::GROUP) |
|||
|
0 ignored issues
–
show
|
|||||
| 111 | 57 | ->cannotBeOverwritten() |
|||
|
0 ignored issues
–
show
|
|||||
| 112 | 57 | ->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 113 | 57 | ->end(); |
|||
| 114 | } |
||||
| 115 | |||||
| 116 | 57 | protected function _tags(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 117 | { |
||||
| 118 | return $node |
||||
| 119 | 57 | ->children() |
|||
| 120 | 57 | ->arrayNode('tags') |
|||
|
0 ignored issues
–
show
|
|||||
| 121 | 57 | ->prototype('scalar')->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 122 | 57 | ->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 123 | 57 | ->end(); |
|||
| 124 | } |
||||
| 125 | |||||
| 126 | 57 | protected function _descr(ArrayNodeDefinition $node): ArrayNodeDefinition |
|||
|
0 ignored issues
–
show
|
|||||
| 127 | { |
||||
| 128 | return $node |
||||
| 129 | 57 | ->children() |
|||
| 130 | 57 | ->scalarNode('descr') |
|||
|
0 ignored issues
–
show
|
|||||
| 131 | 57 | ->defaultNull() |
|||
|
0 ignored issues
–
show
|
|||||
| 132 | 57 | ->end() |
|||
|
0 ignored issues
–
show
|
|||||
| 133 | 57 | ->end(); |
|||
| 134 | } |
||||
| 135 | } |
||||
| 136 |