Issues (113)

lib/RIM/Extensions/ExtAbstractElement.php (9 issues)

Labels
Severity
1
<?php
2
3
/**
4
 * The MIT License
5
 *
6
 * Copyright 2018  Peter Gee <https://github.com/pgee70>.
7
 *
8
 * Permission is hereby granted, free of charge, to any person obtaining a copy
9
 * of this software and associated documentation files (the "Software"), to deal
10
 * in the Software without restriction, including without limitation the rights
11
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
12
 * copies of the Software, and to permit persons to whom the Software is
13
 * furnished to do so, subject to the following conditions:
14
 *
15
 * The above copyright notice and this permission notice shall be included in
16
 * all copies or substantial portions of the Software.
17
 *
18
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20
 * FITNESS FOR A PARTICULAR PURPOSE AND NON INFRINGEMENT. IN NO EVENT SHALL THE
21
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
22
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
23
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
24
 * THE SOFTWARE.
25
 */
26
27
/**
28
 *
29
 * @package     i3Soft\CDA
30
 * @author      Peter Gee <https://github.com/pgee70>
31
 * @link        https://github.com/pgee70/cda
32
 *
33
 */
34
35
36
namespace i3Soft\CDA\RIM\Extensions;
37
38
use i3Soft\CDA\ClinicalDocument as CDA;
39
use i3Soft\CDA\Interfaces\ClassCodeInterface;
40
use i3Soft\CDA\Interfaces\ElementInterface;
41
use i3Soft\CDA\Interfaces\MoodCodeInterface;
42
use i3Soft\CDA\Interfaces\NullFlavourInterface;
43
use i3Soft\CDA\Interfaces\TypeCodeInterface;
44
45
/**
46
 * this abstract element class does not have the realmcode typecode present in AbstractElement.
47
 */
48
abstract class ExtAbstractElement implements ElementInterface, NullFlavourInterface
49
{
50
51
  /**
52
   * @param \DOMDocument $doc
53
   *
54
   * @return \DOMElement
55
   */
56
  protected function createElement (\DOMDocument $doc): \DOMElement
57
  {
58
    /* @var $el \DOMElement */
59
    $el = $doc->createElement(CDA::getNS() . $this->getElementTag());
60
    /** @noinspection PhpUndefinedMethodInspection */
61
    if ($this->hasNullFlavour())
0 ignored issues
show
The method hasNullFlavour() does not exist on i3Soft\CDA\RIM\Extensions\ExtAbstractElement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

61
    if ($this->/** @scrutinizer ignore-call */ hasNullFlavour())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
62
    {
63
      $el->setAttribute(CDA::getNS() . 'nullFlavor', $this->getNullFlavour());
0 ignored issues
show
The method getNullFlavour() does not exist on i3Soft\CDA\RIM\Extensions\ExtAbstractElement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

63
      $el->setAttribute(CDA::getNS() . 'nullFlavor', $this->/** @scrutinizer ignore-call */ getNullFlavour());

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
64
      return $el;
65
    }
66
    // tag can have class code or type code, but not both.
67
    // can have a class code and a mood code, but not type code and mood code
68
    /** @noinspection PhpUndefinedMethodInspection */
69
    if ($this instanceof ClassCodeInterface
70
        && $this->hasClassCode())
0 ignored issues
show
The method hasClassCode() does not exist on i3Soft\CDA\RIM\Extensions\ExtAbstractElement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        && $this->/** @scrutinizer ignore-call */ hasClassCode())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
The method hasClassCode() does not exist on i3Soft\CDA\Interfaces\ClassCodeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to i3Soft\CDA\Interfaces\ClassCodeInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

70
        && $this->/** @scrutinizer ignore-call */ hasClassCode())
Loading history...
71
    {
72
      $el->setAttribute(CDA::getNS() . 'classCode', $this->getClassCode());
73
      /** @noinspection PhpUndefinedMethodInspection */
74
      if ($this instanceof MoodCodeInterface
75
          && $this->hasMoodCode())
0 ignored issues
show
The method hasMoodCode() does not exist on i3Soft\CDA\Interfaces\ClassCodeInterface. It seems like you code against a sub-type of i3Soft\CDA\Interfaces\ClassCodeInterface such as i3Soft\CDA\RIM\Act\Encounter or i3Soft\CDA\RIM\Act\Criterion or i3Soft\CDA\RIM\Extensions\ExtEntitlement or i3Soft\CDA\RIM\Act\ObservationMedia or i3Soft\CDA\Component\XMLBodyComponent or i3Soft\CDA\RIM\Act\Organizer or i3Soft\CDA\Elements\Procedure or i3Soft\CDA\RIM\Extensions\ExtControlAct or i3Soft\CDA\RIM\Act\ObservationRange or i3Soft\CDA\RIM\Act\Supply or i3Soft\CDA\ClinicalDocument or i3Soft\CDA\RIM\Act\Consent or i3Soft\CDA\RIM\Extensions\SubstitutionPermission or i3Soft\CDA\RIM\Act\Act or i3Soft\CDA\RIM\Act\ServiceEvent or i3Soft\CDA\RIM\Act\EncompassingEncounter or i3Soft\CDA\Component\SingleComponent\Section. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
          && $this->/** @scrutinizer ignore-call */ hasMoodCode())
Loading history...
The method hasMoodCode() does not exist on i3Soft\CDA\Interfaces\MoodCodeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to i3Soft\CDA\Interfaces\MoodCodeInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
          && $this->/** @scrutinizer ignore-call */ hasMoodCode())
Loading history...
The method hasMoodCode() does not exist on i3Soft\CDA\RIM\Extensions\ExtAbstractElement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

75
          && $this->/** @scrutinizer ignore-call */ hasMoodCode())

This check looks for calls to methods that do not seem to exist on a given type. It looks for the method on the type itself as well as in inherited classes or implemented interfaces.

This is most likely a typographical error or the method has been renamed.

Loading history...
76
      {
77
        $el->setAttribute(CDA::getNS() . 'moodCode', $this->getMoodCode());
78
      }
79
    }
80
    /** @noinspection PhpUndefinedMethodInspection */
81
    elseif ($this instanceof TypeCodeInterface && $this->hasTypeCode())
0 ignored issues
show
The method hasTypeCode() does not exist on i3Soft\CDA\RIM\Extensions\ExtAbstractElement. Since it exists in all sub-types, consider adding an abstract or default implementation to i3Soft\CDA\RIM\Extensions\ExtAbstractElement. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
    elseif ($this instanceof TypeCodeInterface && $this->/** @scrutinizer ignore-call */ hasTypeCode())
Loading history...
The method hasTypeCode() does not exist on i3Soft\CDA\Interfaces\TypeCodeInterface. Since it exists in all sub-types, consider adding an abstract or default implementation to i3Soft\CDA\Interfaces\TypeCodeInterface. ( Ignorable by Annotation )

If this is a false-positive, you can also ignore this issue in your code via the ignore-call  annotation

81
    elseif ($this instanceof TypeCodeInterface && $this->/** @scrutinizer ignore-call */ hasTypeCode())
Loading history...
82
    {
83
      $el->setAttribute(CDA::getNS() . 'typeCode', $this->getTypeCode());
84
    }
85
    return $el;
86
  }
87
88
  /**
89
   * get the element tag name
90
   *
91
   * @return string
92
   */
93
  abstract protected function getElementTag (): string;
94
}