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_League |
||
| 4 | { |
||
| 5 | protected $api; |
||
| 6 | protected $leagueId; |
||
| 7 | protected $league = NULL; |
||
| 8 | |||
| 9 | /** |
||
| 10 | * Constructor of CoC_League |
||
| 11 | * |
||
| 12 | * @param $leagueId |
||
| 13 | */ |
||
| 14 | public function __construct($league) |
||
| 15 | { |
||
| 16 | $this->api = new ClashOfClans(); |
||
| 17 | if(is_object($league)) |
||
| 18 | { |
||
| 19 | $this->league = $league; |
||
| 20 | } |
||
| 21 | else |
||
| 22 | { |
||
| 23 | $this->leagueId = $league; |
||
| 24 | $this->getLeague(); |
||
| 25 | } |
||
| 26 | } |
||
| 27 | |||
| 28 | /** |
||
| 29 | * Gets an stdClass containing league-information |
||
| 30 | * |
||
| 31 | * @return stdClass, league |
||
|
0 ignored issues
–
show
|
|||
| 32 | */ |
||
| 33 | protected function getLeague() |
||
| 34 | { |
||
| 35 | if($this->league == NULL) |
||
| 36 | { |
||
| 37 | View Code Duplication | foreach ($this->api->getLeagueList()->items as $league) |
|
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
| 38 | { |
||
| 39 | if ($league->id == $this->leagueId) |
||
| 40 | { |
||
| 41 | $this->league = $league; |
||
| 42 | return $this->league; |
||
| 43 | } |
||
| 44 | } |
||
| 45 | return 0; |
||
| 46 | } |
||
| 47 | else |
||
| 48 | { |
||
| 49 | return $this->league; |
||
| 50 | } |
||
| 51 | |||
| 52 | } |
||
| 53 | |||
| 54 | /** |
||
| 55 | * Sets the league by providing it's exact name |
||
| 56 | * |
||
| 57 | * @param string, league name |
||
| 58 | * @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...
|
|||
| 59 | */ |
||
| 60 | public function setLeagueByName($name) |
||
| 61 | { |
||
| 62 | View Code Duplication | foreach ($this->api->getLeagueList()->items as $league) |
|
|
0 ignored issues
–
show
This code seems to be duplicated across 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...
|
|||
| 63 | { |
||
| 64 | if ($league->name == $name) |
||
| 65 | { |
||
| 66 | $this->leagueId = $league->id; |
||
| 67 | $this->league = $league; |
||
| 68 | return 1; |
||
| 69 | } |
||
| 70 | } |
||
| 71 | return 0; |
||
| 72 | } |
||
| 73 | |||
| 74 | /** |
||
| 75 | * Gets the league ID |
||
| 76 | * |
||
| 77 | * @return int |
||
| 78 | */ |
||
| 79 | public function getLeagueId() |
||
| 80 | { |
||
| 81 | return $this->getLeague()->id; |
||
| 82 | } |
||
| 83 | |||
| 84 | /** |
||
| 85 | * Gets the league name |
||
| 86 | * |
||
| 87 | * @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...
|
|||
| 88 | */ |
||
| 89 | public function getLeagueName() |
||
| 90 | { |
||
| 91 | return $this->getLeague()->name; |
||
| 92 | } |
||
| 93 | |||
| 94 | /** |
||
| 95 | * Sets the league by providing it's exact name |
||
| 96 | * |
||
| 97 | * @param (optional) $size ("tiny", "small", "medium") |
||
| 98 | * @return string, URL to the picture |
||
|
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...
|
|||
| 99 | */ |
||
| 100 | public function getLeagueIcon($size = "") //small, tiny, medium |
||
| 101 | { |
||
| 102 | $league = $this->getLeague(); |
||
| 103 | switch ($size) { |
||
| 104 | case "small": |
||
| 105 | return $league->iconUrls->small; |
||
| 106 | break; |
||
|
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. Loading history...
|
|||
| 107 | case "medium": |
||
| 108 | return $league->iconUrls->medium; |
||
| 109 | break; |
||
|
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. Loading history...
|
|||
| 110 | case "tiny": |
||
| 111 | return $league->iconUrls->tiny; |
||
| 112 | break; |
||
|
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. Loading history...
|
|||
| 113 | default: |
||
| 114 | return $league->iconUrls->small; //medium is not always available, so lets chose small on default |
||
| 115 | break; |
||
|
0 ignored issues
–
show
break is not strictly necessary here and could be removed.
The break statement is not necessary if it is preceded for example by a return statement: switch ($x) {
case 1:
return 'foo';
break; // This break is not necessary and can be left off.
}
If you would like to keep this construct to be consistent with other case statements, you can safely mark this issue as a false-positive. Loading history...
|
|||
| 116 | } |
||
| 117 | } |
||
| 118 | } |
||
| 119 | |||
| 120 | ?> |
||
|
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.