Code Duplication    Length = 14-14 lines in 4 locations

src/lib/eveApi.php 4 locations

@@ 99-112 (lines=14) @@
96
 * @param string $typeID
97
 * @return mixed
98
 */
99
function apiCharacterName($typeID)
100
{
101
    $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?IDs={$typeID}";
102
    $xml = makeApiRequest($url);
103
    foreach ($xml->result->rowset->row as $entity) {
104
        $name = $entity->attributes()->name;
105
    }
106
107
    if (!isset($name)) { // Make sure it's always set.
108
        $name = "Unknown";
109
    }
110
111
    return $name;
112
}
113
114
/**
115
 * @param string $typeName
@@ 118-131 (lines=14) @@
115
 * @param string $typeName
116
 * @return mixed
117
 */
118
function apiCharacterID($typeName)
119
{
120
    $url = "https://api.eveonline.com/eve/CharacterID.xml.aspx?names={$typeName}";
121
    $xml = makeApiRequest($url);
122
    foreach ($xml->result->rowset->row as $entity) {
123
        $ID = $entity->attributes()->characterID;
124
    }
125
126
    if (!isset($ID)) { // Make sure it's always set.
127
        $ID = "Unknown";
128
    }
129
130
    return $ID;
131
}
132
133
/**
134
 * @param string $typeID
@@ 137-150 (lines=14) @@
134
 * @param string $typeID
135
 * @return mixed
136
 */
137
function apiTypeName($typeID)
138
{
139
    $url = "https://api.eveonline.com/eve/TypeName.xml.aspx?IDs={$typeID}";
140
    $xml = makeApiRequest($url);
141
    foreach ($xml->result->rowset->row as $entity) {
142
        $name = $entity->attributes()->typeName;
143
    }
144
145
    if (!isset($name)) { // Make sure it's always set.
146
        $name = "Unknown";
147
    }
148
149
    return $name;
150
}
151
152
/**
153
 * @param string $typeName
@@ 156-169 (lines=14) @@
153
 * @param string $typeName
154
 * @return mixed
155
 */
156
function apiTypeID($typeName)
157
{
158
    $url = "https://www.fuzzwork.co.uk/api/typeid.php?typename={$typeName}&format=xml";
159
    $xml = makeApiRequest($url);
160
    foreach ($xml->result->rowset->row as $entity) {
161
        $ID = $entity->attributes()->typeID;
162
    }
163
164
    if (!isset($ID)) { // Make sure it's always set.
165
        $ID = "Unknown";
166
    }
167
168
    return $ID;
169
}