| Conditions | 3 | 
| Paths | 4 | 
| Total Lines | 17 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 0 | ||
| 1 | <?php | ||
| 26 | public function upload($file, string $name, array $additionalArguments = []): array | ||
| 27 |     { | ||
| 28 | /** @var string|false $path */ | ||
| 29 | $path = is_string($file) ? $file : $file->getRealPath(); | ||
| 30 |         if (false === $path) { | ||
| 31 |             throw new \InvalidArgumentException(sprintf('A string or an instance of "SplInfo" is required for uploading the file.')); | ||
| 32 | } | ||
| 33 | |||
| 34 | $arguments = array_merge($additionalArguments, [ | ||
| 35 | 'sound' => DataPart::fromPath($path), | ||
| 36 | 'name' => $name, | ||
| 37 | ]); | ||
| 38 | |||
| 39 | $response = $this->client->request(self::API, 'upload', $arguments); | ||
| 40 | |||
| 41 | return $response->toArray(); // @phpstan-ignore-line | ||
| 42 | } | ||
| 43 | |||
| 55 |