Conditions | 4 |
Paths | 4 |
Total Lines | 42 |
Code Lines | 28 |
Lines | 0 |
Ratio | 0 % |
Changes | 2 | ||
Bugs | 1 | Features | 0 |
1 | <?php |
||
19 | public function run() |
||
20 | { |
||
21 | $localPhotoPath = '/var/www/html/pic_profile_small.jpg'; |
||
22 | |||
23 | $result = (new GetUserProfilePhotos()) |
||
24 | ->setUserId($this->entity->getFrom()->getId()) |
||
25 | ->trigger(); |
||
26 | |||
27 | if ($result instanceof Response) { |
||
28 | /** @var PhotoSize $photoWithMaxSize */ |
||
29 | $photoWithMaxSize = $result |
||
30 | ->getFirstEntity() |
||
31 | ->getPhotoByOffset(0) |
||
32 | ->getPhotoSizeWithMaxFileSize(); |
||
33 | |||
34 | $result = (new GetFile()) |
||
35 | ->setFileId($photoWithMaxSize->getFileId()) |
||
36 | ->trigger(); |
||
37 | |||
38 | if ($result instanceof Response) { |
||
39 | $downloadedFile = $result |
||
40 | ->getFirstEntity() |
||
41 | ->download('/var/www/html/pic_profile_small.jpg'); |
||
42 | |||
43 | if ($downloadedFile) { |
||
44 | (new SendChatAction()) |
||
45 | ->setChatId($this->getChatId()) |
||
46 | ->setAction(SendChatAction::ACTION_UPLOAD_PHOTO) |
||
47 | ->trigger(); |
||
48 | |||
49 | sleep(2); |
||
50 | |||
51 | (new SendPhoto()) |
||
52 | ->setChatId($this->getChatId()) |
||
53 | ->setPhoto($localPhotoPath) |
||
54 | ->trigger(); |
||
55 | |||
56 | unlink($localPhotoPath); |
||
57 | } |
||
58 | } |
||
59 | } |
||
60 | } |
||
61 | } |
||
62 |