dimaslanjaka /
universal-framework
| 1 | <?php |
||||
| 2 | |||||
| 3 | namespace Proxy; |
||||
| 4 | |||||
| 5 | $GLOBALS['proxy_loaded'] = null; |
||||
| 6 | |||||
| 7 | class db |
||||
| 8 | { |
||||
| 9 | /** |
||||
| 10 | * PDO. |
||||
| 11 | * |
||||
| 12 | * @var \DB\pdo |
||||
| 13 | */ |
||||
| 14 | private $pdo = null; |
||||
| 15 | |||||
| 16 | public function __construct(\DB\pdo $pdo) |
||||
| 17 | { |
||||
| 18 | global $GLOBALS; |
||||
| 19 | if (!$GLOBALS['proxy_loaded']) { |
||||
| 20 | $this->load_proxies_db(); |
||||
| 21 | } |
||||
| 22 | $this->pdo = $pdo; |
||||
| 23 | } |
||||
| 24 | |||||
| 25 | public function random_proxy(int $n = 1) |
||||
|
0 ignored issues
–
show
|
|||||
| 26 | { |
||||
| 27 | } |
||||
| 28 | |||||
| 29 | public function inactive_proxies() |
||||
| 30 | { |
||||
| 31 | return $this->pdo->query("SELECT * FROM `proxies` WHERE `status` = 'inactive'")->row_array(); |
||||
| 32 | } |
||||
| 33 | |||||
| 34 | public function load_proxies_db() |
||||
| 35 | { |
||||
| 36 | $proxies = $this->pdo |
||||
| 37 | ->select('proxies') |
||||
| 38 | ->where(['country' => null, 'status' => 'active']) |
||||
| 39 | ->row_array(); |
||||
| 40 | \Filemanager\file::file(__DIR__ . '/proxies/db.json', $proxies, true); |
||||
|
0 ignored issues
–
show
It seems like
$proxies can also be of type array; however, parameter $create of Filemanager\file::file() does only seem to accept boolean, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 41 | |||||
| 42 | return $proxies; |
||||
| 43 | } |
||||
| 44 | |||||
| 45 | public function load_proxies() |
||||
| 46 | { |
||||
| 47 | return json_decode(\Filemanager\file::get(__DIR__ . '/proxies/db.json')); |
||||
|
0 ignored issues
–
show
It seems like
Filemanager\file::get(__..._ . '/proxies/db.json') can also be of type null; however, parameter $json of json_decode() does only seem to accept string, maybe add an additional type check?
(
Ignorable by Annotation
)
If this is a false-positive, you can also ignore this issue in your code via the
Loading history...
|
|||||
| 48 | } |
||||
| 49 | } |
||||
| 50 |
This check looks for parameters that have been defined for a function or method, but which are not used in the method body.