@@ -37,56 +37,56 @@ |
||
37 | 37 | * @since 15.0.0 |
38 | 38 | */ |
39 | 39 | class ZipResponse extends Response implements ICallbackResponse { |
40 | - /** @var resource[] Files to be added to the zip response */ |
|
41 | - private $resources = []; |
|
42 | - /** @var string Filename that the zip file should have */ |
|
43 | - private $name; |
|
44 | - private $request; |
|
40 | + /** @var resource[] Files to be added to the zip response */ |
|
41 | + private $resources = []; |
|
42 | + /** @var string Filename that the zip file should have */ |
|
43 | + private $name; |
|
44 | + private $request; |
|
45 | 45 | |
46 | - /** |
|
47 | - * @since 15.0.0 |
|
48 | - */ |
|
49 | - public function __construct(IRequest $request, string $name = 'output') { |
|
50 | - parent::__construct(); |
|
46 | + /** |
|
47 | + * @since 15.0.0 |
|
48 | + */ |
|
49 | + public function __construct(IRequest $request, string $name = 'output') { |
|
50 | + parent::__construct(); |
|
51 | 51 | |
52 | - $this->name = $name; |
|
53 | - $this->request = $request; |
|
54 | - } |
|
52 | + $this->name = $name; |
|
53 | + $this->request = $request; |
|
54 | + } |
|
55 | 55 | |
56 | - /** |
|
57 | - * @since 15.0.0 |
|
58 | - */ |
|
59 | - public function addResource($r, string $internalName, int $size, int $time = -1) { |
|
60 | - if (!\is_resource($r)) { |
|
61 | - throw new \InvalidArgumentException('No resource provided'); |
|
62 | - } |
|
56 | + /** |
|
57 | + * @since 15.0.0 |
|
58 | + */ |
|
59 | + public function addResource($r, string $internalName, int $size, int $time = -1) { |
|
60 | + if (!\is_resource($r)) { |
|
61 | + throw new \InvalidArgumentException('No resource provided'); |
|
62 | + } |
|
63 | 63 | |
64 | - $this->resources[] = [ |
|
65 | - 'resource' => $r, |
|
66 | - 'internalName' => $internalName, |
|
67 | - 'size' => $size, |
|
68 | - 'time' => $time, |
|
69 | - ]; |
|
70 | - } |
|
64 | + $this->resources[] = [ |
|
65 | + 'resource' => $r, |
|
66 | + 'internalName' => $internalName, |
|
67 | + 'size' => $size, |
|
68 | + 'time' => $time, |
|
69 | + ]; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * @since 15.0.0 |
|
74 | - */ |
|
75 | - public function callback(IOutput $output) { |
|
76 | - $size = 0; |
|
77 | - $files = count($this->resources); |
|
72 | + /** |
|
73 | + * @since 15.0.0 |
|
74 | + */ |
|
75 | + public function callback(IOutput $output) { |
|
76 | + $size = 0; |
|
77 | + $files = count($this->resources); |
|
78 | 78 | |
79 | - foreach ($this->resources as $resource) { |
|
80 | - $size += $resource['size']; |
|
81 | - } |
|
79 | + foreach ($this->resources as $resource) { |
|
80 | + $size += $resource['size']; |
|
81 | + } |
|
82 | 82 | |
83 | - $zip = new Streamer($this->request, $size, $files); |
|
84 | - $zip->sendHeaders($this->name); |
|
83 | + $zip = new Streamer($this->request, $size, $files); |
|
84 | + $zip->sendHeaders($this->name); |
|
85 | 85 | |
86 | - foreach ($this->resources as $resource) { |
|
87 | - $zip->addFileFromStream($resource['resource'], $resource['internalName'], $resource['size'], $resource['time']); |
|
88 | - } |
|
86 | + foreach ($this->resources as $resource) { |
|
87 | + $zip->addFileFromStream($resource['resource'], $resource['internalName'], $resource['size'], $resource['time']); |
|
88 | + } |
|
89 | 89 | |
90 | - $zip->finalize(); |
|
91 | - } |
|
90 | + $zip->finalize(); |
|
91 | + } |
|
92 | 92 | } |