These results are based on our legacy PHP analysis, consider migrating to our new PHP analysis engine instead. Learn more
1 | <?php |
||
2 | /** |
||
3 | * Example of usage Yandex\Disk package |
||
4 | * |
||
5 | * @author Alexander Mitsura |
||
6 | * @created 15.10.13 10:40 |
||
7 | */ |
||
8 | |||
9 | $settings = require_once '../../settings.php'; |
||
10 | |||
11 | use Yandex\OAuth\OAuthClient; |
||
12 | |||
13 | $client = new OAuthClient($settings['global']['clientId']); |
||
14 | |||
15 | View Code Duplication | if (isset($_COOKIE['yaAccessToken'])) { |
|
0 ignored issues
–
show
|
|||
16 | |||
17 | $target = $_POST['target']; |
||
18 | $destination = $_POST['destination']; |
||
19 | |||
20 | $client->setAccessToken($_COOKIE['yaAccessToken']); |
||
21 | |||
22 | // XXX: how it should be (using user access token) |
||
23 | //$diskClient = new \Yandex\Disk\DiskClient($client->getAccessToken()); |
||
24 | |||
25 | // XXX: how it is now (using magic access token) |
||
26 | $diskClient = new \Yandex\Disk\DiskClient($client->getAccessToken()); |
||
27 | |||
28 | $diskClient->setServiceScheme(\Yandex\Disk\DiskClient::HTTPS_SCHEME); |
||
29 | |||
30 | header('Content-type: application/json'); |
||
31 | $response = []; |
||
32 | |||
33 | if ($diskClient->move($target, $destination)) { |
||
34 | $response['status'] = 'OK'; |
||
35 | } |
||
36 | |||
37 | echo json_encode($response); |
||
38 | } |
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.