Passed
Pull Request — dev (#179)
by Bob
02:48
created

eveApi.php ➔ systemName()   A

Complexity

Conditions 3
Paths 4

Size

Total Lines 22
Code Lines 15

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 3
eloc 15
nc 4
nop 1
dl 0
loc 22
rs 9.2
c 0
b 0
f 0
1
<?php
2
/**
3
 * The MIT License (MIT)
4
 *
5
 * Copyright (c) 2016 Robert Sardinia
6
 *
7
 * Permission is hereby granted, free of charge, to any person obtaining a copy
8
 * of this software and associated documentation files (the "Software"), to deal
9
 * in the Software without restriction, including without limitation the rights
10
 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11
 * copies of the Software, and to permit persons to whom the Software is
12
 * furnished to do so, subject to the following conditions:
13
 *
14
 * The above copyright notice and this permission notice shall be included in all
15
 * copies or substantial portions of the Software.
16
 *
17
 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18
 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19
 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
20
 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21
 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22
 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23
 * SOFTWARE.
24
 */
25
26
use Monolog\Handler\StreamHandler;
27
use Monolog\Logger;
28
29
/**
30
 * @param $url
31
 * @return SimpleXMLElement|null|string
32
 */
33
function makeApiRequest($url)
34
{
35
    $logger = new Logger('eveApi');
36
    $logger->pushHandler(new StreamHandler(__DIR__ . '/../../log/libraryError.log', Logger::DEBUG));
37
    try {
38
        // Initialize a new request for this URL
39
        $ch = curl_init($url);
40
        // Set the options for this request
41
        curl_setopt_array($ch, array(
42
            CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect
43
            CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data
44
            CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate
45
            CURLOPT_USERAGENT => 'Dramiel Discord Bot - https://github.com/shibdib/Dramiel', // Useragent
46
            CURLOPT_TIMEOUT => 15,
47
        ));
48
        // Fetch the data from the URL
49
        $data = curl_exec($ch);
50
        // Close the connection
51
        curl_close($ch);
52
        // Return a new SimpleXMLElement based upon the received data
53
        return new SimpleXMLElement($data);
54
    } catch (Exception $e) {
55
        $logger->error('EVE API Error: ' . $e->getMessage());
56
        return null;
57
    }
58
}
59
60
/**
61
 * @return mixed|null
62
 */
63
64
function serverStatus()
65
{
66
    $logger = new Logger('eveApi');
67
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
68
    try {
69
        // Initialize a new request for this URL
70
        $ch = curl_init('https://api.eveonline.com/server/ServerStatus.xml.aspx');
71
        // Set the options for this request
72
        curl_setopt_array($ch, array(
73
            CURLOPT_FOLLOWLOCATION => true, // Yes, we want to follow a redirect
74
            CURLOPT_RETURNTRANSFER => true, // Yes, we want that curl_exec returns the fetched data
75
            CURLOPT_TIMEOUT => 8,
76
            CURLOPT_SSL_VERIFYPEER => true, // Do not verify the SSL certificate
77
        ));
78
        // Fetch the data from the URL
79
        $data = curl_exec($ch);
80
        // Close the connection
81
        curl_close($ch);
82
83
        $true = 'true';
84
        //If server is down return false
85
        if ($data->serverOpen !== 'True') {
86
            return FALSE;
87
        }
88
        //If server is up return true
89
        return $true;
90
    } catch (Exception $e) {
91
        $logger->error('EVE API Error: ' . $e->getMessage());
92
        return null;
93
    }
94
}
95
96
/**
97
 * @param string $characterID
98
 * @return mixed
99
 */
100
////Char ID to name via CCP
101 View Code Duplication
function characterName($characterID)
102
{
103
    $character = characterDetails($characterID);
104
    $name = (string)$character['name'];
105
    if (null === $name || '' === $name) { // Make sure it's always set.
106
        $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?ids={$characterID}";
107
        $xml = makeApiRequest($url);
108
        foreach ($xml->result->rowset->row as $entity) {
109
            $name = $entity->attributes()->name;
110
        }
111
    }
112
    return $name;
113
}
114
115
/**
116
 * @param string $characterName
117
 * @return mixed
118
 */
119
////Character name to ID
120 View Code Duplication
function characterID($characterName)
121
{
122
    $logger = new Logger('eveESI');
123
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
124
    $characterName = urlencode($characterName);
125
    $url = "https://esi.tech.ccp.is/latest/search/?search={$characterName}&categories=character&language=en-us&strict=true&datasource=tranquility";
126
127
    try {
128
        $json = file_get_contents($url);
129
        $data = json_decode($json, TRUE);
130
        $id = (int)$data['character'][0];
131
132
    } catch (Exception $e) {
133
        $logger->error('EVE ESI Error: ' . $e->getMessage());
134
        $url = "https://api.eveonline.com/eve/CharacterID.xml.aspx?names={$characterName}";
135
        $xml = makeApiRequest($url);
136
        foreach ($xml->result->rowset->row as $entity) {
137
            $id = $entity->attributes()->characterID;
138
        }
139
    }
140
141
    return $id;
0 ignored issues
show
Bug introduced by
The variable $id does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
142
}
143
144
/**
145
 * @param string $characterID
146
 * @return mixed
147
 */
148
////Char ID to char data via CCP
149 View Code Duplication
function characterDetails($characterID)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
150
{
151
    $logger = new Logger('eveESI');
152
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
153
    $url = "https://esi.tech.ccp.is/latest/characters/{$characterID}/";
154
155
    try {
156
        $json = file_get_contents($url);
157
        $data = json_decode($json, TRUE);
158
159
    } catch (Exception $e) {
160
        $logger->error('EVE ESI Error: ' . $e->getMessage());
161
        return null;
162
    }
163
164
    return $data;
165
}
166
167
/**
168
 * @param string $systemID
169
 * @return mixed
170
 */
171
////System ID to name via CCP
172
function systemName($systemID)
173
{
174
    $logger = new Logger('eveESI');
175
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
176
    $url = "https://esi.tech.ccp.is/latest/universe/systems/{$systemID}/";
177
178
    try {
179
        $json = file_get_contents($url);
180
        $data = json_decode($json, TRUE);
181
        $name = (string)$data['solar_system_name'];
182
183
    } catch (Exception $e) {
184
        $logger->error('EVE ESI Error: ' . $e->getMessage());
185
        $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?ids={$systemID}";
186
        $xml = makeApiRequest($url);
187
        foreach ($xml->result->rowset->row as $entity) {
188
            $name = $entity->attributes()->name;
189
        }
190
    }
191
192
    return $name;
0 ignored issues
show
Bug introduced by
The variable $name does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
193
}
194
195
/**
196
 * @param string $corpName
197
 * @return mixed
198
 */
199
////Corp name to ID
200 View Code Duplication
function corpID($corpName)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
201
{
202
    $logger = new Logger('eveESI');
203
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
204
    $corpName = urlencode($corpName);
205
    $url = "https://esi.tech.ccp.is/latest/search/?search={$corpName}&categories=corporation&language=en-us&strict=true&datasource=tranquility";
206
207
    try {
208
        $json = file_get_contents($url);
209
        $data = json_decode($json, TRUE);
210
        $id = (int)$data['corporation'][0];
211
212
    } catch (Exception $e) {
213
        $logger->error('EVE ESI Error: ' . $e->getMessage());
214
        $url = "https://api.eveonline.com/eve/CharacterID.xml.aspx?names={$corpName}";
215
        $xml = makeApiRequest($url);
216
        foreach ($xml->result->rowset->row as $entity) {
217
            $id = $entity->attributes()->characterID;
218
        }
219
    }
220
221
    return $id;
0 ignored issues
show
Bug introduced by
The variable $id does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
222
}
223
224
225
/**
226
 * @param string $corpID
227
 * @return mixed
228
 */
229
////Corp ID to name via CCP
230 View Code Duplication
function corpName($corpID)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
231
{
232
    $corporation = corpDetails($corpID);
233
    $name = (string)$corporation['corporation_name'];
234
    if (null === $name || '' === $name) { // Make sure it's always set.
235
        $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?ids={$corpID}";
236
        $xml = makeApiRequest($url);
237
        foreach ($xml->result->rowset->row as $entity) {
238
            $name = $entity->attributes()->name;
239
        }
240
    }
241
242
    return $name;
243
}
244
245
/**
246
 * @param string $corpID
247
 * @return mixed
248
 */
249
////Corp ID to corp data via CCP
250 View Code Duplication
function corpDetails($corpID)
0 ignored issues
show
Duplication introduced by
This function seems to be duplicated in your project.

Duplicated code is one of the most pungent code smells. If you need to duplicate the same code in three or more different places, we strongly encourage you to look into extracting the code into a single class or operation.

You can also find more detailed suggestions in the “Code” section of your repository.

Loading history...
251
{
252
    $logger = new Logger('eveESI');
253
    $logger->pushHandler(new StreamHandler(__DIR__ . '../../log/libraryError.log', Logger::DEBUG));
254
    $url = "https://esi.tech.ccp.is/latest/corporations/{$corpID}/";
255
256
    try {
257
        $json = file_get_contents($url);
258
        $data = json_decode($json, TRUE);
259
260
    } catch (Exception $e) {
261
        $logger->error('EVE ESI Error: ' . $e->getMessage());
262
        return null;
263
    }
264
265
    return $data;
266
}
267
268
/**
269
 * @param string $allianceID
270
 * @return mixed
271
 */
272
////Alliance ID to name via CCP
273
function allianceName($allianceID)
274
{
275
    $url = "https://esi.tech.ccp.is/latest/alliances/{$allianceID}/";
276
277
    try {
278
        $json = file_get_contents($url);
279
        $data = json_decode($json, TRUE);
280
        $name = (string)$data['alliance_name'];
281
282
    } catch (Exception $e) {
283
        $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?ids={$allianceID}";
284
        $xml = makeApiRequest($url);
285
        foreach ($xml->result->rowset->row as $entity) {
286
            $name = $entity->attributes()->name;
287
        }
288
    }
289
290
    return $name;
0 ignored issues
show
Bug introduced by
The variable $name does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
291
}
292
293
/**
294
 * @param string $systemName
295
 * @return mixed
296
 */
297
////System name to ID
298
function systemID($systemName)
299
{
300
    $systemName = urlencode($systemName);
301
    $url = "https://esi.tech.ccp.is/latest/search/?search={$systemName}&categories=solarsystem&language=en-us&strict=true&datasource=tranquility";
302
303
    try {
304
        $json = file_get_contents($url);
305
        $data = json_decode($json, TRUE);
306
        $id = (int)$data['solarsystem'][0];
307
308
    } catch (Exception $e) {
309
        $logger->error('EVE ESI Error: ' . $e->getMessage());
0 ignored issues
show
Bug introduced by
The variable $logger does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
310
        $url = "https://api.eveonline.com/eve/CharacterID.xml.aspx?names={$systemName}";
311
        $xml = makeApiRequest($url);
312
        foreach ($xml->result->rowset->row as $entity) {
313
            $id = $entity->attributes()->characterID;
314
        }
315
    }
316
317
    return $id;
0 ignored issues
show
Bug introduced by
The variable $id does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
318
}
319
320
/**
321
 * @param string $typeID
322
 * @return mixed
323
 */
324
////TypeID to TypeName via CCP
325
function apiTypeName($typeID)
326
{
327
    $url = "https://esi.tech.ccp.is/latest/universe/types/{$typeID}/";
328
329
    try {
330
        $json = file_get_contents($url);
331
        $data = json_decode($json, TRUE);
332
        $name = (string)$data['type_name'];
333
334
    } catch (Exception $e) {
335
        $logger->error('EVE ESI Error: ' . $e->getMessage());
0 ignored issues
show
Bug introduced by
The variable $logger does not exist. Did you forget to declare it?

This check marks access to variables or properties that have not been declared yet. While PHP has no explicit notion of declaring a variable, accessing it before a value is assigned to it is most likely a bug.

Loading history...
336
        $url = "https://api.eveonline.com/eve/TypeName.xml.aspx?ids={$typeID}";
337
        $xml = makeApiRequest($url);
338
        foreach ($xml->result->rowset->row as $entity) {
339
            $name = $entity->attributes()->typeName;
340
        }
341
    }
342
343
    return $name;
0 ignored issues
show
Bug introduced by
The variable $name does not seem to be defined for all execution paths leading up to this point.

If you define a variable conditionally, it can happen that it is not defined for all execution paths.

Let’s take a look at an example:

function myFunction($a) {
    switch ($a) {
        case 'foo':
            $x = 1;
            break;

        case 'bar':
            $x = 2;
            break;
    }

    // $x is potentially undefined here.
    echo $x;
}

In the above example, the variable $x is defined if you pass “foo” or “bar” as argument for $a. However, since the switch statement has no default case statement, if you pass any other value, the variable $x would be undefined.

Available Fixes

  1. Check for existence of the variable explicitly:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        if (isset($x)) { // Make sure it's always set.
            echo $x;
        }
    }
    
  2. Define a default value for the variable:

    function myFunction($a) {
        $x = ''; // Set a default which gets overridden for certain paths.
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
        }
    
        echo $x;
    }
    
  3. Add a value for the missing path:

    function myFunction($a) {
        switch ($a) {
            case 'foo':
                $x = 1;
                break;
    
            case 'bar':
                $x = 2;
                break;
    
            // We add support for the missing case.
            default:
                $x = '';
                break;
        }
    
        echo $x;
    }
    
Loading history...
344
}
345
346
/**
347
 * @param string $typeName
348
 * @return mixed
349
 */
350
////TypeName to TypeID via fuzz
351
function apiTypeID($typeName)
352
{
353
    $typeName = urlencode($typeName);
354
    $url = "https://www.fuzzwork.co.uk/api/typeid.php?typename={$typeName}";
355
    $json = file_get_contents($url);
356
    $data = json_decode($json, TRUE);
357
    $id = (int)$data['typeID'];
358
359
    if (null === $id) { // Make sure it's always set.
360
        $id = 'Unknown';
361
    }
362
363
    return $id;
364
}
365
366
////Char/Object ID to name via CCP
367
function apiMoonName($moonID)
368
{
369
    $url = "https://api.eveonline.com/eve/CharacterName.xml.aspx?IDs={$moonID}";
370
    $xml = makeApiRequest($url);
371
    $name = null;
372
    foreach ($xml->result->rowset->row as $entity) {
373
        $name = $entity->attributes()->name;
374
    }
375
    if (null === $name) { // Make sure it's always set.
376
        $name = 'Unknown';
377
    }
378
    return $name;
379
}