1n9i9c7om /
ClashOfClans-API-PHP
This project does not seem to handle request data directly as such no vulnerable execution paths were found.
include, or for example
via PHP's auto-loading mechanism.
These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
| 1 | <?php |
||
| 2 | |||
| 3 | class CoC_Location |
||
| 4 | { |
||
| 5 | protected $api; |
||
| 6 | protected $locationId; |
||
| 7 | protected $location = NULL; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Constructor of CoC_Location |
||
| 11 | * |
||
| 12 | * @param $locationId |
||
| 13 | */ |
||
| 14 | public function __construct($location) |
||
| 15 | { |
||
| 16 | $this->api = new ClashOfClans(); |
||
| 17 | if(is_object($location)) |
||
| 18 | { |
||
| 19 | $this->location = $location; |
||
| 20 | } |
||
| 21 | else |
||
| 22 | { |
||
| 23 | $this->locationId = $location; |
||
| 24 | $this->getLocation(); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Gets an stdClass containing location-information |
||
| 30 | * |
||
| 31 | * @return stdClass, location |
||
|
0 ignored issues
–
show
|
|||
| 32 | */ |
||
| 33 | protected function getLocation() |
||
| 34 | { |
||
| 35 | if($this->location == NULL) |
||
| 36 | { |
||
| 37 | foreach ($this->api->getLocationList()->items as $location) |
||
| 38 | { |
||
| 39 | if ($location->id == $this->locationId) |
||
| 40 | { |
||
| 41 | $this->location = $location; |
||
| 42 | return $this->location; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | return 0; |
||
| 46 | } |
||
| 47 | else |
||
| 48 | { |
||
| 49 | return $this->location; |
||
| 50 | } |
||
| 51 | } |
||
| 52 | |||
| 53 | /** |
||
| 54 | * Sets the location by providing it's exact name |
||
| 55 | * |
||
| 56 | * @param string, location name |
||
| 57 | * @return bool, success or fail |
||
|
0 ignored issues
–
show
The doc-type
bool, could not be parsed: Expected "|" or "end of type", but got "," at position 4. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 58 | */ |
||
| 59 | View Code Duplication | public function setLocationByName($name) |
|
|
0 ignored issues
–
show
This method 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...
|
|||
| 60 | { |
||
| 61 | foreach ($this->api->getLocationList()->items as $location) |
||
| 62 | { |
||
| 63 | if ($location->name == $name) |
||
| 64 | { |
||
| 65 | $this->locationId = $location->id; |
||
| 66 | $this->location = $location; |
||
| 67 | return 1; |
||
| 68 | } |
||
| 69 | } |
||
| 70 | return 0; |
||
| 71 | } |
||
| 72 | |||
| 73 | /** |
||
| 74 | * Sets the location by providing it's country code |
||
| 75 | * |
||
| 76 | * @param string |
||
| 77 | * @return bool |
||
| 78 | */ |
||
| 79 | View Code Duplication | public function setLocationByCode($cc) |
|
|
0 ignored issues
–
show
This method 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...
|
|||
| 80 | { |
||
| 81 | foreach ($this->api->getLocationList()->items as $location) |
||
| 82 | { |
||
| 83 | if ($location->countryCode == $cc) |
||
| 84 | { |
||
| 85 | $this->locationId = $location->id; |
||
| 86 | $this->location = $location; |
||
| 87 | return 1; |
||
| 88 | } |
||
| 89 | } |
||
| 90 | return 0; |
||
| 91 | } |
||
| 92 | |||
| 93 | /** |
||
| 94 | * Gets the location ID |
||
| 95 | * |
||
| 96 | * @return int |
||
| 97 | */ |
||
| 98 | public function getLocationId() |
||
| 99 | { |
||
| 100 | return $this->getLocation()->id; |
||
| 101 | } |
||
| 102 | |||
| 103 | /** |
||
| 104 | * Gets the location name |
||
| 105 | * |
||
| 106 | * @return string, name |
||
|
0 ignored issues
–
show
The doc-type
string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 107 | */ |
||
| 108 | public function getLocationName() |
||
| 109 | { |
||
| 110 | return $this->getLocation()->name; |
||
| 111 | } |
||
| 112 | |||
| 113 | /** |
||
| 114 | * Check whether the given location is a country or a region |
||
| 115 | * |
||
| 116 | * @return bool |
||
| 117 | */ |
||
| 118 | public function isCountry() |
||
| 119 | { |
||
| 120 | return $this->getLocation()->isCountry; |
||
| 121 | } |
||
| 122 | |||
| 123 | /** |
||
| 124 | * Gets the country code for the given location |
||
| 125 | * |
||
| 126 | * @return string, country code |
||
|
0 ignored issues
–
show
The doc-type
string, could not be parsed: Expected "|" or "end of type", but got "," at position 6. (view supported doc-types)
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types. Loading history...
|
|||
| 127 | */ |
||
| 128 | public function getCountryCode() |
||
| 129 | { |
||
| 130 | if($this->isCountry()) |
||
| 131 | { |
||
| 132 | return $this->getLocation()->countryCode; |
||
| 133 | } |
||
| 134 | else |
||
| 135 | { |
||
| 136 | return "nA"; |
||
| 137 | } |
||
| 138 | } |
||
| 139 | } |
||
| 140 | |||
| 141 | ?> |
||
|
0 ignored issues
–
show
It is not recommended to use PHP's closing tag
?> in files other than templates.
Using a closing tag in PHP files that only contain PHP code is not recommended as you might accidentally add whitespace after the closing tag which would then be output by PHP. This can cause severe problems, for example headers cannot be sent anymore. A simple precaution is to leave off the closing tag as it is not required, and it also has no negative effects whatsoever. Loading history...
|
This check marks PHPDoc comments that could not be parsed by our parser. To see which comment annotations we can parse, please refer to our documentation on supported doc-types.