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