Issues (113)

lib/RIM/Extensions/ExtEntitlement.php (8 issues)

1
<?php
2
3
4
/**
5
 * The MIT License
6
 *
7
 * Copyright 2018  Peter Gee <https://github.com/pgee70>.
8
 *
9
 * Permission is hereby granted, free of charge, to any person obtaining a copy
10
 * of this software and associated documentation files (the "Software"), to deal
11
 * in the Software without restriction, including without limitation the rights
12
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
13
 * copies of the Software, and to permit persons to whom the Software is
14
 * furnished to do so, subject to the following conditions:
15
 *
16
 * The above copyright notice and this permission notice shall be included in
17
 * all copies or substantial portions of the Software.
18
 *
19
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
22
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
24
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
25
 * THE SOFTWARE.
26
 */
27
28
namespace i3Soft\CDA\RIM\Extensions;
29
30
/**
31
 *
32
 * @package     i3Soft\CDA
33
 * @author      Peter Gee <https://github.com/pgee70>
34
 * @link        https://github.com/pgee70/cda
35
 *
36
 */
37
38
39
use i3Soft\CDA\Elements\AbstractElement;
40
use i3Soft\CDA\Interfaces\ClassCodeInterface;
41
use i3Soft\CDA\Interfaces\MoodCodeInterface;
42
use i3Soft\CDA\Traits\ClassCodeTrait;
43
use i3Soft\CDA\Traits\ExtCodeTrait;
44
use i3Soft\CDA\Traits\ExtEffectiveTimeTrait;
45
use i3Soft\CDA\Traits\ExtIdTrait;
46
use i3Soft\CDA\Traits\ExtParticipantTrait;
47
use i3Soft\CDA\Traits\MoodCodeTrait;
48
49
/**
50
 * Class ExtEntitlement
51
 *
52
 * @package i3Soft\CDA\RIM\Extensions
53
 */
54
class ExtEntitlement extends AbstractElement implements ClassCodeInterface, MoodCodeInterface
55
{
56
  use ClassCodeTrait;
57
  use MoodCodeTrait;
58
  use ExtIdTrait;
59
  use ExtCodeTrait;
60
  use ExtEffectiveTimeTrait;
61
  use ExtParticipantTrait;
62
63
  /**
64
   * ExtEntitlement constructor.
65
   *
66
   * @param null $ext_id
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ext_id is correct as it would always require null to be passed?
Loading history...
67
   * @param null $ext_code
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ext_code is correct as it would always require null to be passed?
Loading history...
68
   * @param null $ext_effective_time
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ext_effective_time is correct as it would always require null to be passed?
Loading history...
69
   * @param null $ext_participant
0 ignored issues
show
Documentation Bug introduced by
Are you sure the doc-type for parameter $ext_participant is correct as it would always require null to be passed?
Loading history...
70
   */
71
  public function __construct (
72
    $ext_id = NULL,
73
    $ext_code = NULL,
74
    $ext_effective_time = NULL,
75
    $ext_participant = NULL
76
  ) {
77
    $this->setAcceptableClassCodes(['', ClassCodeInterface::COVERAGE])
78
      ->setAcceptableMoodCodes(['', MoodCodeInterface::EVENT])
79
      ->setClassCode(ClassCodeInterface::COVERAGE)
80
      ->setMoodCode(MoodCodeInterface::EVENT);
81
    if ($ext_id && $ext_id instanceof ExtId)
0 ignored issues
show
$ext_id is of type null, thus it always evaluated to false.
Loading history...
82
    {
83
      $this->setExtId($ext_id);
84
    }
85
    if ($ext_code && $ext_code instanceof ExtCode)
0 ignored issues
show
$ext_code is of type null, thus it always evaluated to false.
Loading history...
86
    {
87
      $this->setExtCode($ext_code);
88
    }
89
    if ($ext_effective_time && $ext_effective_time instanceof ExtEffectiveTime)
0 ignored issues
show
$ext_effective_time is of type null, thus it always evaluated to false.
Loading history...
90
    {
91
      $this->setExtEffectiveTime($ext_effective_time);
92
    }
93
    if ($ext_participant && $ext_participant instanceof ExtParticipant)
0 ignored issues
show
$ext_participant is of type null, thus it always evaluated to false.
Loading history...
94
    {
95
      $this->setExtParticipant($ext_participant);
96
    }
97
  }
98
99
  /**
100
   * @param \DOMDocument $doc
101
   *
102
   * @return \DOMElement
103
   */
104
  public function toDOMElement (\DOMDocument $doc): \DOMElement
105
  {
106
    $el = $this->createElement($doc);
107
    $this->renderExtId($el, $doc)
108
      ->renderExtCode($el, $doc)
109
      ->renderExtEffectiveTime($el, $doc)
110
      ->renderExtParticipant($el, $doc);
111
    return $el;
112
  }
113
114
115
  /**
116
   * @return string
117
   */
118
  protected function getElementTag (): string
119
  {
120
    return 'ext:entitlement';
121
  }
122
123
}