/** * Can perform any special checks needed to be performed before sending the actual request to Telegram * * This will return an array with data that will be different in each case (for now). This can be changed in the * future. * * @param TelegramMethods $method * @return array */ public function checkSpecialConditions(TelegramMethods $method) : array { $method->performSpecialConditions(); $return = [false]; foreach ($method as $key => $value) { if (is_object($value)) { if ($value instanceof InputFile) { // If we are about to send a file, we must use the multipart/form-data way $this->formType = 'multipart/form-data'; $return = ['id' => $key, 'stream' => $value->getStream()]; } } } return $return; }
public function performSpecialConditions() : TelegramMethods { $this->results = json_encode($this->results); return parent::performSpecialConditions(); }
/** * Can perform any special checks needed to be performed before sending the actual request to Telegram * * This will return an array with data that will be different in each case (for now). This can be changed in the * future. * * @param TelegramMethods $method * @return array */ private function checkSpecialConditions(TelegramMethods $method) : array { $this->logger->debug('Checking whether to apply special conditions to this request'); $method->performSpecialConditions(); $return = [false]; foreach ($method as $key => $value) { if (is_object($value) && $value instanceof InputFile) { $this->logger->debug('About to send a file, so changing request to use multi-part instead'); // If we are about to send a file, we must use the multipart/form-data way $this->formType = 'multipart/form-data'; $return = ['id' => $key, 'stream' => $value->getStream()]; } } return $return; }