vikkio88 /
dsManager-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 | |||
| 4 | namespace App\Lib\DsManager\Helpers; |
||
| 5 | |||
| 6 | |||
| 7 | use App\Lib\DsManager\Models\Orm\LeagueRound; |
||
| 8 | use App\Lib\DsManager\Models\Orm\Match; |
||
| 9 | use App\Lib\DsManager\Models\Orm\Match as MatchOrm; |
||
| 10 | use App\Lib\DsManager\Models\Orm\MatchResult; |
||
| 11 | |||
| 12 | /** |
||
| 13 | * Class MatchSimulator |
||
| 14 | * @package App\Lib\DsManager\Helpers |
||
| 15 | */ |
||
| 16 | class MatchSimulator |
||
| 17 | { |
||
| 18 | /** |
||
| 19 | * @param $roundId |
||
| 20 | * @return string |
||
| 21 | */ |
||
| 22 | public static function simulateRound($roundId) |
||
| 23 | { |
||
| 24 | $result = self::getCompleteRound($roundId); |
||
| 25 | if (!empty($result) |
||
| 26 | && |
||
| 27 | !$result->simulated |
||
| 28 | ) { |
||
| 29 | $matches = Match::where( |
||
| 30 | [ |
||
| 31 | 'league_round_id' => $roundId |
||
| 32 | ] |
||
| 33 | )->get(); |
||
| 34 | foreach ($matches as $match) { |
||
| 35 | self::simulateSimpleResult($match->id)->toArray(); |
||
| 36 | } |
||
| 37 | LeagueRound::find($roundId)->update(['simulated' => true]); |
||
| 38 | $result = self::getCompleteRound($roundId); |
||
| 39 | } |
||
| 40 | return $result; |
||
| 41 | } |
||
| 42 | |||
| 43 | /** |
||
| 44 | * @param $matchId |
||
| 45 | * @return mixed |
||
| 46 | */ |
||
| 47 | View Code Duplication | public static function simulateCompleteResult($matchId) |
|
|
0 ignored issues
–
show
|
|||
| 48 | { |
||
| 49 | $result = self::getCompleteResult($matchId); |
||
| 50 | if (!empty($result) |
||
| 51 | && !$result->simulated |
||
|
0 ignored issues
–
show
The property
simulated does not exist on object<App\Lib\DsManager\Models\Orm\MatchResult>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 52 | && self::simulate($matchId) === 1 |
||
| 53 | ) { |
||
| 54 | $result = self::getCompleteResult($matchId); |
||
| 55 | } |
||
| 56 | return $result; |
||
| 57 | } |
||
| 58 | |||
| 59 | /** |
||
| 60 | * @param $matchId |
||
| 61 | * @return mixed |
||
| 62 | */ |
||
| 63 | View Code Duplication | public static function simulateSimpleResult($matchId) |
|
|
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...
|
|||
| 64 | { |
||
| 65 | $result = self::getSimpleResult($matchId); |
||
| 66 | if (!empty($result) |
||
| 67 | && !$result->simulated |
||
|
0 ignored issues
–
show
The property
simulated does not exist on object<App\Lib\DsManager\Models\Orm\MatchResult>. Since you implemented __get, maybe consider adding a @property annotation.
Since your code implements the magic getter <?php
/**
* @property int $x
* @property int $y
* @property string $text
*/
class MyLabel
{
private $properties;
private $allowedProperties = array('x', 'y', 'text');
public function __get($name)
{
if (isset($properties[$name]) && in_array($name, $this->allowedProperties)) {
return $properties[$name];
} else {
return null;
}
}
public function __set($name, $value)
{
if (in_array($name, $this->allowedProperties)) {
$properties[$name] = $value;
} else {
throw new \LogicException("Property $name is not defined.");
}
}
}
If the property has read access only, you can use the @property-read annotation instead. Of course, you may also just have mistyped another name, in which case you should fix the error. See also the PhpDoc documentation for @property. Loading history...
|
|||
| 68 | && self::simulate($matchId) === 1 |
||
| 69 | ) { |
||
| 70 | $result = self::getSimpleResult($matchId); |
||
| 71 | } |
||
| 72 | return $result; |
||
| 73 | } |
||
| 74 | |||
| 75 | /** |
||
| 76 | * @param $matchId |
||
| 77 | * @return mixed |
||
| 78 | */ |
||
| 79 | private static function simulate($matchId) |
||
| 80 | { |
||
| 81 | $match = \App\Lib\DsManager\Models\Match::fromArray( |
||
| 82 | MatchOrm::complete() |
||
|
0 ignored issues
–
show
The method
complete() does not exist on App\Lib\DsManager\Models\Orm\Match. Did you maybe mean scopeComplete()?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. Loading history...
|
|||
| 83 | ->where( |
||
| 84 | [ |
||
| 85 | 'id' => $matchId |
||
| 86 | ] |
||
| 87 | )->first()->toArray() |
||
| 88 | ); |
||
| 89 | $matchResult = $match->simulate()->toArray(); |
||
| 90 | $result = MatchResult::where( |
||
| 91 | [ |
||
| 92 | 'id' => $matchId |
||
| 93 | ] |
||
| 94 | )->update( |
||
| 95 | MatchResult::resolveAttributes( |
||
| 96 | $matchResult, |
||
| 97 | $matchId |
||
| 98 | ) |
||
| 99 | ); |
||
| 100 | return $result; |
||
| 101 | } |
||
| 102 | |||
| 103 | |||
| 104 | /** |
||
| 105 | * @param $matchId |
||
| 106 | * @return MatchResult |
||
| 107 | */ |
||
| 108 | private static function getCompleteResult($matchId) |
||
| 109 | { |
||
| 110 | return MatchResult::complete()->where( |
||
| 111 | [ |
||
| 112 | 'id' => $matchId |
||
| 113 | ] |
||
| 114 | )->first(); |
||
| 115 | } |
||
| 116 | |||
| 117 | /** |
||
| 118 | * @param $matchId |
||
| 119 | * @return MatchResult |
||
| 120 | */ |
||
| 121 | private static function getSimpleResult($matchId) |
||
| 122 | { |
||
| 123 | return MatchResult::teams()->where( |
||
| 124 | [ |
||
| 125 | 'id' => $matchId |
||
| 126 | ] |
||
| 127 | )->first(); |
||
| 128 | } |
||
| 129 | |||
| 130 | /** |
||
| 131 | * @param $roundId |
||
| 132 | * @return mixed |
||
| 133 | */ |
||
| 134 | private static function getCompleteRound($roundId) |
||
| 135 | { |
||
| 136 | return LeagueRound::complete()->where( |
||
|
0 ignored issues
–
show
The method
complete() does not exist on App\Lib\DsManager\Models\Orm\LeagueRound. Did you maybe mean scopeComplete()?
This check marks calls to methods that do not seem to exist on an object. This is most likely the result of a method being renamed without all references to it being renamed likewise. Loading history...
|
|||
| 137 | [ |
||
| 138 | 'id' => $roundId |
||
| 139 | ] |
||
| 140 | )->first(); |
||
| 141 | } |
||
| 142 | |||
| 143 | } |
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.