matomo
/
app
/
vendor
/
prefixed
/
symfony
/
polyfill-php81
/
Resources
/
stubs
/
CURLStringFile.php
CURLStringFile.php
46 lines
| 1 | <?php |
| 2 | |
| 3 | namespace Matomo\Dependencies; |
| 4 | |
| 5 | /* |
| 6 | * This file is part of the Symfony package. |
| 7 | * |
| 8 | * (c) Fabien Potencier <fabien@symfony.com> |
| 9 | * |
| 10 | * For the full copyright and license information, please view the LICENSE |
| 11 | * file that was distributed with this source code. |
| 12 | */ |
| 13 | if (\PHP_VERSION_ID >= 70400 && \extension_loaded('curl')) { |
| 14 | /** |
| 15 | * @property string $data |
| 16 | */ |
| 17 | class CURLStringFile extends \CURLFile |
| 18 | { |
| 19 | private $data; |
| 20 | public function __construct(string $data, string $postname, string $mime = 'application/octet-stream') |
| 21 | { |
| 22 | $this->data = $data; |
| 23 | parent::__construct('data://application/octet-stream;base64,' . \base64_encode($data), $mime, $postname); |
| 24 | } |
| 25 | public function __set(string $name, $value) : void |
| 26 | { |
| 27 | if ('data' !== $name) { |
| 28 | $this->{$name} = $value; |
| 29 | return; |
| 30 | } |
| 31 | if (\is_object($value) ? !\method_exists($value, '__toString') : !\is_scalar($value)) { |
| 32 | throw new \TypeError('Cannot assign ' . \gettype($value) . ' to property CURLStringFile::$data of type string'); |
| 33 | } |
| 34 | $this->name = 'data://application/octet-stream;base64,' . \base64_encode($value); |
| 35 | } |
| 36 | public function __isset(string $name) : bool |
| 37 | { |
| 38 | return isset($this->{$name}); |
| 39 | } |
| 40 | public function &__get(string $name) |
| 41 | { |
| 42 | return $this->{$name}; |
| 43 | } |
| 44 | } |
| 45 | } |
| 46 |