Completed
Push — master ( d8c1bc...81b29b )
by Jakub
02:46
created

Slash   A

Complexity

Total Complexity 4

Size/Duplication

Total Lines 25
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 14
c 1
b 0
f 1
dl 0
loc 25
ccs 11
cts 11
cp 1
rs 10
wmc 4

4 Methods

Rating   Name   Duplication   Size   Complexity  
A getNamespace() 0 2 1
A configureItemOptions() 0 8 1
A configureChannelOptions() 0 1 1
A getName() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss\Extensions;
5
6
use Nexendrie\Rss\Generator;
7
use Symfony\Component\OptionsResolver\OptionsResolver;
8
9
/**
10
 * Slash
11
 *
12
 * @author Jakub Konečný
13
 */
14 1
final class Slash extends BaseExtension {
15
  public const ELEMENT_SECTION = "section";
16
  public const ELEMENT_DEPARTMENT = "department";
17
  public const ELEMENT_COMMENTS = "comments";
18
  public const ELEMENT_HIT_PARADE = "hit_parade";
19
20
  public function getName(): string {
21 1
    return "slash";
22
  }
23
24
  public function getNamespace(): string {
25 1
    return "http://purl.org/rss/1.0/modules/slash/";
26
  }
27
28
  public function configureChannelOptions(OptionsResolver $resolver, Generator $generator): void {
29 1
  }
30
31
  public function configureItemOptions(OptionsResolver $resolver, Generator $generator): void {
1 ignored issue
show
introduced by
The method parameter $generator is never used
Loading history...
32 1
    $this->registerElements($resolver);
33 1
    $resolver->setAllowedTypes($this->getElementName(self::ELEMENT_SECTION), "string");
34 1
    $resolver->setAllowedTypes($this->getElementName(self::ELEMENT_DEPARTMENT), "string");
35 1
    $resolver->setAllowedTypes($this->getElementName(self::ELEMENT_COMMENTS), "int");
36 1
    $resolver->setAllowedTypes($this->getElementName(self::ELEMENT_HIT_PARADE), "string");
37 1
    $resolver->setAllowedValues($this->getElementName(self::ELEMENT_HIT_PARADE), function(string $value) {
38 1
      return (preg_match('#^\d(,\d)*$#', $value) === 1);
39 1
    });
40 1
  }
41
}
42
43
?>