Debian Codegraph @

vendor/wikimedia/shellbox/src/Command/OutputGlobToUrl.php

raw
1 <?php
2
3 namespace Shellbox\Command;
4
5 use GuzzleHttp\Psr7\Uri;
6 use Psr\Http\Message\UriInterface;
7
8 /**
9 * An OutputGlob for files that are sent to a server with PUT requests.
10 * @since 4.1.0
11 */
12 class OutputGlobToUrl extends OutputGlob {
13 /** @var UriInterface */
14 private $destUri;
15
16 /**
17 * @internal
18 * @param string $prefix
19 * @param string $extension
20 * @param string|UriInterface $destUrl
21 */
22 public function __construct( string $prefix, string $extension, $destUrl ) {
23 parent::__construct( $prefix, $extension );
24 if ( $destUrl instanceof UriInterface ) {
25 $this->destUri = $destUrl;
26 } else {
27 $this->destUri = new Uri( $destUrl );
28 }
29 }
30
31 public function getOutputFile( $boxedName ) {
32 $path = $this->destUri->getPath() . basename( $boxedName );
33 $instance = new OutputFileToUrl( $this->destUri->withPath( $path ) );
34 $this->files[$boxedName] = $instance;
35 return $instance;
36 }
37
38 public function getClientData() {
39 return parent::getClientData() + [
40 'type' => 'url',
41 'url' => (string)$this->destUri,
42 ];
43 }
44 }