StreetNameType::__construct()   A
last analyzed

Complexity

Conditions 2
Paths 2

Size

Total Lines 36
Code Lines 31

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 31
dl 0
loc 36
rs 9.424
c 0
b 0
f 0
cc 2
nc 2
nop 1
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\Elements\Address;
29
30
use i3Soft\CDA\Elements\AbstractSimpleElement;
31
32
/**
33
 *
34
 * @package     i3Soft\CDA
35
 * @author      Peter Gee <https://github.com/pgee70>
36
 * @link        https://github.com/pgee70/cda
37
 *
38
 */
39
class StreetNameType extends AbstractSimpleElement
40
{
41
  const Alley     = 'Ally';
42
  const Arcade    = 'Arc';
43
  const Avenue    = 'Ave';
44
  const Boulevard = 'Bvd';
45
  const Bypass    = 'Bypa';
46
  const Circuit   = 'Cct';
47
  const Close     = 'Cl';
48
  const Corner    = 'Crn';
49
  const Court     = 'Ct';
50
  const Crescent  = 'Cres';
51
  const CulDeSac  = 'Cds';
52
  const Drive     = 'Dr';
53
  const Esplanade = 'Esp';
54
  const Green     = 'Grn';
55
  const Grove     = 'Gr';
56
  const Highway   = 'Hwy';
57
  const Junction  = 'Jnc';
58
  const Lane      = 'Lane';
59
  const Link      = 'Link';
60
  const Mews      = 'Mews';
61
  const Parade    = 'Pde';
62
  const Place     = 'Pl';
63
  const Ridge     = 'Rdge';
64
  const Road      = 'Rd';
65
  const Square    = 'Sq';
66
  const Street    = 'St';
67
  const Terrace   = 'Tce';
68
69
70
  public function __construct (string $value)
71
  {
72
    $acceptable_values = array(
73
      self::Alley,
74
      self::Arcade,
75
      self::Avenue,
76
      self::Boulevard,
77
      self::Bypass,
78
      self::Circuit,
79
      self::Close,
80
      self::Corner,
81
      self::Court,
82
      self::Crescent,
83
      self::CulDeSac,
84
      self::Drive,
85
      self::Esplanade,
86
      self::Green,
87
      self::Grove,
88
      self::Highway,
89
      self::Junction,
90
      self::Lane,
91
      self::Link,
92
      self::Mews,
93
      self::Parade,
94
      self::Place,
95
      self::Ridge,
96
      self::Road,
97
      self::Square,
98
      self::Street,
99
      self::Terrace,
100
    );
101
    if (\in_array($value, $acceptable_values, TRUE) === FALSE)
102
    {
103
      throw new \InvalidArgumentException("The street type value of $value is not acceptable!");
104
    }
105
    parent::__construct($value);
106
  }
107
108
  /**
109
   * @return string
110
   */
111
  protected function getElementTag (): string
112
  {
113
    return 'streetNameType';
114
  }
115
}
116