RssChannelItem   A
last analyzed

Complexity

Total Complexity 7

Size/Duplication

Total Lines 27
Duplicated Lines 0 %

Test Coverage

Coverage 100%

Importance

Changes 9
Bugs 0 Features 2
Metric Value
eloc 15
c 9
b 0
f 2
dl 0
loc 27
ccs 15
cts 15
cp 1
rs 10
wmc 7

3 Methods

Rating   Name   Duplication   Size   Complexity  
A toXml() 0 12 4
A configureOptions() 0 3 2
A __construct() 0 2 1
1
<?php
2
declare(strict_types=1);
3
4
namespace Nexendrie\Rss;
5
6
use Symfony\Component\OptionsResolver\OptionsResolver;
7
8
/**
9
 * Rss Channel Item
10
 *
11
 * @author Jakub Konečný
12
 */
13 1
final class RssChannelItem {
14
  use \Nette\SmartObject;
15
16
  private array $data;
17
18
  public function __construct(array $data) {
19 1
    $this->data = $data;
20 1
  }
21
22
  private function configureOptions(OptionsResolver $resolver, Generator $generator): void {
23 1
    foreach($generator->extensions as $extension) {
24 1
      $extension->configureItemOptions($resolver, $generator);
25
    }
26 1
  }
27
28
  public function toXml(\SimpleXMLElement &$element, Generator $generator): void {
29 1
    $resolver = new OptionsResolver();
30 1
    $this->configureOptions($resolver, $generator);
31 1
    $data = $resolver->resolve($this->data);
32 1
    foreach($data as $key => $value) {
33 1
      if($value === "") {
34 1
        continue;
35
      }
36 1
      if(!$value instanceof IXmlConvertible) {
37 1
        $value = new GenericElement($key, $value);
38
      }
39 1
      $value->appendToXml($element);
40
    }
41 1
  }
42
}
43
?>