@@ -33,31 +33,31 @@ |
||
33 | 33 | * @package OCA\UpdateNotification |
34 | 34 | */ |
35 | 35 | class ResetTokenBackgroundJob extends TimedJob { |
36 | - /** @var IConfig */ |
|
37 | - private $config; |
|
38 | - /** @var ITimeFactory */ |
|
39 | - private $timeFactory; |
|
36 | + /** @var IConfig */ |
|
37 | + private $config; |
|
38 | + /** @var ITimeFactory */ |
|
39 | + private $timeFactory; |
|
40 | 40 | |
41 | - /** |
|
42 | - * @param IConfig $config |
|
43 | - * @param ITimeFactory $timeFactory |
|
44 | - */ |
|
45 | - public function __construct(IConfig $config, |
|
46 | - ITimeFactory $timeFactory) { |
|
47 | - // Run all 10 minutes |
|
48 | - $this->setInterval(60 * 10); |
|
49 | - $this->config = $config; |
|
50 | - $this->timeFactory = $timeFactory; |
|
51 | - } |
|
41 | + /** |
|
42 | + * @param IConfig $config |
|
43 | + * @param ITimeFactory $timeFactory |
|
44 | + */ |
|
45 | + public function __construct(IConfig $config, |
|
46 | + ITimeFactory $timeFactory) { |
|
47 | + // Run all 10 minutes |
|
48 | + $this->setInterval(60 * 10); |
|
49 | + $this->config = $config; |
|
50 | + $this->timeFactory = $timeFactory; |
|
51 | + } |
|
52 | 52 | |
53 | - /** |
|
54 | - * @param $argument |
|
55 | - */ |
|
56 | - protected function run($argument) { |
|
57 | - // Delete old tokens after 2 days |
|
58 | - if($this->timeFactory->getTime() - $this->config->getAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()) >= 172800) { |
|
59 | - $this->config->deleteSystemValue('updater.secret'); |
|
60 | - } |
|
61 | - } |
|
53 | + /** |
|
54 | + * @param $argument |
|
55 | + */ |
|
56 | + protected function run($argument) { |
|
57 | + // Delete old tokens after 2 days |
|
58 | + if($this->timeFactory->getTime() - $this->config->getAppValue('core', 'updater.secret.created', $this->timeFactory->getTime()) >= 172800) { |
|
59 | + $this->config->deleteSystemValue('updater.secret'); |
|
60 | + } |
|
61 | + } |
|
62 | 62 | |
63 | 63 | } |
@@ -35,89 +35,89 @@ |
||
35 | 35 | |
36 | 36 | class AvatarHome implements ICollection { |
37 | 37 | |
38 | - /** @var array */ |
|
39 | - private $principalInfo; |
|
40 | - /** @var IAvatarManager */ |
|
41 | - private $avatarManager; |
|
42 | - |
|
43 | - /** |
|
44 | - * AvatarHome constructor. |
|
45 | - * |
|
46 | - * @param array $principalInfo |
|
47 | - * @param IAvatarManager $avatarManager |
|
48 | - */ |
|
49 | - public function __construct($principalInfo, IAvatarManager $avatarManager) { |
|
50 | - $this->principalInfo = $principalInfo; |
|
51 | - $this->avatarManager = $avatarManager; |
|
52 | - } |
|
53 | - |
|
54 | - public function createFile($name, $data = null) { |
|
55 | - throw new Forbidden('Permission denied to create a file'); |
|
56 | - } |
|
57 | - |
|
58 | - public function createDirectory($name) { |
|
59 | - throw new Forbidden('Permission denied to create a folder'); |
|
60 | - } |
|
61 | - |
|
62 | - public function getChild($name) { |
|
63 | - $elements = pathinfo($name); |
|
64 | - $ext = isset($elements['extension']) ? $elements['extension'] : ''; |
|
65 | - $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); |
|
66 | - if (!in_array($ext, ['jpeg', 'png'], true)) { |
|
67 | - throw new MethodNotAllowed('File format not allowed'); |
|
68 | - } |
|
69 | - if ($size <= 0 || $size > 1024) { |
|
70 | - throw new MethodNotAllowed('Invalid image size'); |
|
71 | - } |
|
72 | - $avatar = $this->avatarManager->getAvatar($this->getName()); |
|
73 | - if (!$avatar->exists()) { |
|
74 | - throw new NotFound(); |
|
75 | - } |
|
76 | - return new AvatarNode($size, $ext, $avatar); |
|
77 | - } |
|
78 | - |
|
79 | - public function getChildren() { |
|
80 | - try { |
|
81 | - return [ |
|
82 | - $this->getChild('96.jpeg') |
|
83 | - ]; |
|
84 | - } catch(NotFound $exception) { |
|
85 | - return []; |
|
86 | - } |
|
87 | - } |
|
88 | - |
|
89 | - public function childExists($name) { |
|
90 | - try { |
|
91 | - $ret = $this->getChild($name); |
|
92 | - return $ret !== null; |
|
93 | - } catch (NotFound $ex) { |
|
94 | - return false; |
|
95 | - } catch (MethodNotAllowed $ex) { |
|
96 | - return false; |
|
97 | - } |
|
98 | - } |
|
99 | - |
|
100 | - public function delete() { |
|
101 | - throw new Forbidden('Permission denied to delete this folder'); |
|
102 | - } |
|
103 | - |
|
104 | - public function getName() { |
|
105 | - list(,$name) = Uri\split($this->principalInfo['uri']); |
|
106 | - return $name; |
|
107 | - } |
|
108 | - |
|
109 | - public function setName($name) { |
|
110 | - throw new Forbidden('Permission denied to rename this folder'); |
|
111 | - } |
|
112 | - |
|
113 | - /** |
|
114 | - * Returns the last modification time, as a unix timestamp |
|
115 | - * |
|
116 | - * @return int|null |
|
117 | - */ |
|
118 | - public function getLastModified() { |
|
119 | - return null; |
|
120 | - } |
|
38 | + /** @var array */ |
|
39 | + private $principalInfo; |
|
40 | + /** @var IAvatarManager */ |
|
41 | + private $avatarManager; |
|
42 | + |
|
43 | + /** |
|
44 | + * AvatarHome constructor. |
|
45 | + * |
|
46 | + * @param array $principalInfo |
|
47 | + * @param IAvatarManager $avatarManager |
|
48 | + */ |
|
49 | + public function __construct($principalInfo, IAvatarManager $avatarManager) { |
|
50 | + $this->principalInfo = $principalInfo; |
|
51 | + $this->avatarManager = $avatarManager; |
|
52 | + } |
|
53 | + |
|
54 | + public function createFile($name, $data = null) { |
|
55 | + throw new Forbidden('Permission denied to create a file'); |
|
56 | + } |
|
57 | + |
|
58 | + public function createDirectory($name) { |
|
59 | + throw new Forbidden('Permission denied to create a folder'); |
|
60 | + } |
|
61 | + |
|
62 | + public function getChild($name) { |
|
63 | + $elements = pathinfo($name); |
|
64 | + $ext = isset($elements['extension']) ? $elements['extension'] : ''; |
|
65 | + $size = (int)(isset($elements['filename']) ? $elements['filename'] : '64'); |
|
66 | + if (!in_array($ext, ['jpeg', 'png'], true)) { |
|
67 | + throw new MethodNotAllowed('File format not allowed'); |
|
68 | + } |
|
69 | + if ($size <= 0 || $size > 1024) { |
|
70 | + throw new MethodNotAllowed('Invalid image size'); |
|
71 | + } |
|
72 | + $avatar = $this->avatarManager->getAvatar($this->getName()); |
|
73 | + if (!$avatar->exists()) { |
|
74 | + throw new NotFound(); |
|
75 | + } |
|
76 | + return new AvatarNode($size, $ext, $avatar); |
|
77 | + } |
|
78 | + |
|
79 | + public function getChildren() { |
|
80 | + try { |
|
81 | + return [ |
|
82 | + $this->getChild('96.jpeg') |
|
83 | + ]; |
|
84 | + } catch(NotFound $exception) { |
|
85 | + return []; |
|
86 | + } |
|
87 | + } |
|
88 | + |
|
89 | + public function childExists($name) { |
|
90 | + try { |
|
91 | + $ret = $this->getChild($name); |
|
92 | + return $ret !== null; |
|
93 | + } catch (NotFound $ex) { |
|
94 | + return false; |
|
95 | + } catch (MethodNotAllowed $ex) { |
|
96 | + return false; |
|
97 | + } |
|
98 | + } |
|
99 | + |
|
100 | + public function delete() { |
|
101 | + throw new Forbidden('Permission denied to delete this folder'); |
|
102 | + } |
|
103 | + |
|
104 | + public function getName() { |
|
105 | + list(,$name) = Uri\split($this->principalInfo['uri']); |
|
106 | + return $name; |
|
107 | + } |
|
108 | + |
|
109 | + public function setName($name) { |
|
110 | + throw new Forbidden('Permission denied to rename this folder'); |
|
111 | + } |
|
112 | + |
|
113 | + /** |
|
114 | + * Returns the last modification time, as a unix timestamp |
|
115 | + * |
|
116 | + * @return int|null |
|
117 | + */ |
|
118 | + public function getLastModified() { |
|
119 | + return null; |
|
120 | + } |
|
121 | 121 | |
122 | 122 | |
123 | 123 | } |
@@ -23,19 +23,19 @@ |
||
23 | 23 | // WARNING: this should be moved to proper AppFramework handling |
24 | 24 | // Check if we are a user |
25 | 25 | if (!\OC::$server->getUserSession()->isLoggedIn()) { |
26 | - header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( |
|
27 | - 'core.login.showLoginForm', |
|
28 | - [ |
|
29 | - 'redirect_url' => \OC::$server->getRequest()->getRequestUri(), |
|
30 | - ] |
|
31 | - ) |
|
32 | - ); |
|
33 | - exit(); |
|
26 | + header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute( |
|
27 | + 'core.login.showLoginForm', |
|
28 | + [ |
|
29 | + 'redirect_url' => \OC::$server->getRequest()->getRequestUri(), |
|
30 | + ] |
|
31 | + ) |
|
32 | + ); |
|
33 | + exit(); |
|
34 | 34 | } |
35 | 35 | // Redirect to 2FA challenge selection if 2FA challenge was not solved yet |
36 | 36 | if (\OC::$server->getTwoFactorAuthManager()->needsSecondFactor(\OC::$server->getUserSession()->getUser())) { |
37 | - header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge')); |
|
38 | - exit(); |
|
37 | + header('Location: ' . \OC::$server->getURLGenerator()->linkToRoute('core.TwoFactorChallenge.selectChallenge')); |
|
38 | + exit(); |
|
39 | 39 | } |
40 | 40 | |
41 | 41 | $tmpl = new OCP\Template('systemtags', 'list', ''); |
@@ -30,35 +30,35 @@ |
||
30 | 30 | * @since 12.0.0 |
31 | 31 | */ |
32 | 32 | interface ICloudId { |
33 | - /** |
|
34 | - * The remote cloud id |
|
35 | - * |
|
36 | - * @return string |
|
37 | - * @since 12.0.0 |
|
38 | - */ |
|
39 | - public function getId(): string; |
|
33 | + /** |
|
34 | + * The remote cloud id |
|
35 | + * |
|
36 | + * @return string |
|
37 | + * @since 12.0.0 |
|
38 | + */ |
|
39 | + public function getId(): string; |
|
40 | 40 | |
41 | - /** |
|
42 | - * Get a clean representation of the cloud id for display |
|
43 | - * |
|
44 | - * @return string |
|
45 | - * @since 12.0.0 |
|
46 | - */ |
|
47 | - public function getDisplayId(): string; |
|
41 | + /** |
|
42 | + * Get a clean representation of the cloud id for display |
|
43 | + * |
|
44 | + * @return string |
|
45 | + * @since 12.0.0 |
|
46 | + */ |
|
47 | + public function getDisplayId(): string; |
|
48 | 48 | |
49 | - /** |
|
50 | - * The username on the remote server |
|
51 | - * |
|
52 | - * @return string |
|
53 | - * @since 12.0.0 |
|
54 | - */ |
|
55 | - public function getUser(): string; |
|
49 | + /** |
|
50 | + * The username on the remote server |
|
51 | + * |
|
52 | + * @return string |
|
53 | + * @since 12.0.0 |
|
54 | + */ |
|
55 | + public function getUser(): string; |
|
56 | 56 | |
57 | - /** |
|
58 | - * The base address of the remote server |
|
59 | - * |
|
60 | - * @return string |
|
61 | - * @since 12.0.0 |
|
62 | - */ |
|
63 | - public function getRemote(): string; |
|
57 | + /** |
|
58 | + * The base address of the remote server |
|
59 | + * |
|
60 | + * @return string |
|
61 | + * @since 12.0.0 |
|
62 | + */ |
|
63 | + public function getRemote(): string; |
|
64 | 64 | } |
@@ -31,33 +31,33 @@ |
||
31 | 31 | * @since 12.0.0 |
32 | 32 | */ |
33 | 33 | interface ICloudIdManager { |
34 | - /** |
|
35 | - * @param string $cloudId |
|
36 | - * @return ICloudId |
|
37 | - * @throws \InvalidArgumentException |
|
38 | - * |
|
39 | - * @since 12.0.0 |
|
40 | - */ |
|
41 | - public function resolveCloudId(string $cloudId): ICloudId; |
|
34 | + /** |
|
35 | + * @param string $cloudId |
|
36 | + * @return ICloudId |
|
37 | + * @throws \InvalidArgumentException |
|
38 | + * |
|
39 | + * @since 12.0.0 |
|
40 | + */ |
|
41 | + public function resolveCloudId(string $cloudId): ICloudId; |
|
42 | 42 | |
43 | - /** |
|
44 | - * Get the cloud id for a remote user |
|
45 | - * |
|
46 | - * @param string $user |
|
47 | - * @param string $remote |
|
48 | - * @return ICloudId |
|
49 | - * |
|
50 | - * @since 12.0.0 |
|
51 | - */ |
|
52 | - public function getCloudId(string $user, string $remote): ICloudId; |
|
43 | + /** |
|
44 | + * Get the cloud id for a remote user |
|
45 | + * |
|
46 | + * @param string $user |
|
47 | + * @param string $remote |
|
48 | + * @return ICloudId |
|
49 | + * |
|
50 | + * @since 12.0.0 |
|
51 | + */ |
|
52 | + public function getCloudId(string $user, string $remote): ICloudId; |
|
53 | 53 | |
54 | - /** |
|
55 | - * Check if the input is a correctly formatted cloud id |
|
56 | - * |
|
57 | - * @param string $cloudId |
|
58 | - * @return bool |
|
59 | - * |
|
60 | - * @since 12.0.0 |
|
61 | - */ |
|
62 | - public function isValidCloudId(string $cloudId): bool; |
|
54 | + /** |
|
55 | + * Check if the input is a correctly formatted cloud id |
|
56 | + * |
|
57 | + * @param string $cloudId |
|
58 | + * @return bool |
|
59 | + * |
|
60 | + * @since 12.0.0 |
|
61 | + */ |
|
62 | + public function isValidCloudId(string $cloudId): bool; |
|
63 | 63 | } |
@@ -29,87 +29,87 @@ |
||
29 | 29 | use OCP\Federation\ICloudIdManager; |
30 | 30 | |
31 | 31 | class CloudIdManager implements ICloudIdManager { |
32 | - /** |
|
33 | - * @param string $cloudId |
|
34 | - * @return ICloudId |
|
35 | - * @throws \InvalidArgumentException |
|
36 | - */ |
|
37 | - public function resolveCloudId(string $cloudId): ICloudId { |
|
38 | - // TODO magic here to get the url and user instead of just splitting on @ |
|
32 | + /** |
|
33 | + * @param string $cloudId |
|
34 | + * @return ICloudId |
|
35 | + * @throws \InvalidArgumentException |
|
36 | + */ |
|
37 | + public function resolveCloudId(string $cloudId): ICloudId { |
|
38 | + // TODO magic here to get the url and user instead of just splitting on @ |
|
39 | 39 | |
40 | - if (!$this->isValidCloudId($cloudId)) { |
|
41 | - throw new \InvalidArgumentException('Invalid cloud id'); |
|
42 | - } |
|
40 | + if (!$this->isValidCloudId($cloudId)) { |
|
41 | + throw new \InvalidArgumentException('Invalid cloud id'); |
|
42 | + } |
|
43 | 43 | |
44 | - // Find the first character that is not allowed in user names |
|
45 | - $id = $this->fixRemoteURL($cloudId); |
|
46 | - $posSlash = strpos($id, '/'); |
|
47 | - $posColon = strpos($id, ':'); |
|
44 | + // Find the first character that is not allowed in user names |
|
45 | + $id = $this->fixRemoteURL($cloudId); |
|
46 | + $posSlash = strpos($id, '/'); |
|
47 | + $posColon = strpos($id, ':'); |
|
48 | 48 | |
49 | - if ($posSlash === false && $posColon === false) { |
|
50 | - $invalidPos = \strlen($id); |
|
51 | - } else if ($posSlash === false) { |
|
52 | - $invalidPos = $posColon; |
|
53 | - } else if ($posColon === false) { |
|
54 | - $invalidPos = $posSlash; |
|
55 | - } else { |
|
56 | - $invalidPos = min($posSlash, $posColon); |
|
57 | - } |
|
49 | + if ($posSlash === false && $posColon === false) { |
|
50 | + $invalidPos = \strlen($id); |
|
51 | + } else if ($posSlash === false) { |
|
52 | + $invalidPos = $posColon; |
|
53 | + } else if ($posColon === false) { |
|
54 | + $invalidPos = $posSlash; |
|
55 | + } else { |
|
56 | + $invalidPos = min($posSlash, $posColon); |
|
57 | + } |
|
58 | 58 | |
59 | - // Find the last @ before $invalidPos |
|
60 | - $pos = $lastAtPos = 0; |
|
61 | - while ($lastAtPos !== false && $lastAtPos <= $invalidPos) { |
|
62 | - $pos = $lastAtPos; |
|
63 | - $lastAtPos = strpos($id, '@', $pos + 1); |
|
64 | - } |
|
59 | + // Find the last @ before $invalidPos |
|
60 | + $pos = $lastAtPos = 0; |
|
61 | + while ($lastAtPos !== false && $lastAtPos <= $invalidPos) { |
|
62 | + $pos = $lastAtPos; |
|
63 | + $lastAtPos = strpos($id, '@', $pos + 1); |
|
64 | + } |
|
65 | 65 | |
66 | - if ($pos !== false) { |
|
67 | - $user = substr($id, 0, $pos); |
|
68 | - $remote = substr($id, $pos + 1); |
|
69 | - if (!empty($user) && !empty($remote)) { |
|
70 | - return new CloudId($id, $user, $remote); |
|
71 | - } |
|
72 | - } |
|
73 | - throw new \InvalidArgumentException('Invalid cloud id'); |
|
74 | - } |
|
66 | + if ($pos !== false) { |
|
67 | + $user = substr($id, 0, $pos); |
|
68 | + $remote = substr($id, $pos + 1); |
|
69 | + if (!empty($user) && !empty($remote)) { |
|
70 | + return new CloudId($id, $user, $remote); |
|
71 | + } |
|
72 | + } |
|
73 | + throw new \InvalidArgumentException('Invalid cloud id'); |
|
74 | + } |
|
75 | 75 | |
76 | - /** |
|
77 | - * @param string $user |
|
78 | - * @param string $remote |
|
79 | - * @return CloudId |
|
80 | - */ |
|
81 | - public function getCloudId(string $user, string $remote): ICloudId { |
|
82 | - // TODO check what the correct url is for remote (asking the remote) |
|
83 | - return new CloudId($user. '@' . $remote, $user, $remote); |
|
84 | - } |
|
76 | + /** |
|
77 | + * @param string $user |
|
78 | + * @param string $remote |
|
79 | + * @return CloudId |
|
80 | + */ |
|
81 | + public function getCloudId(string $user, string $remote): ICloudId { |
|
82 | + // TODO check what the correct url is for remote (asking the remote) |
|
83 | + return new CloudId($user. '@' . $remote, $user, $remote); |
|
84 | + } |
|
85 | 85 | |
86 | - /** |
|
87 | - * Strips away a potential file names and trailing slashes: |
|
88 | - * - http://localhost |
|
89 | - * - http://localhost/ |
|
90 | - * - http://localhost/index.php |
|
91 | - * - http://localhost/index.php/s/{shareToken} |
|
92 | - * |
|
93 | - * all return: http://localhost |
|
94 | - * |
|
95 | - * @param string $remote |
|
96 | - * @return string |
|
97 | - */ |
|
98 | - protected function fixRemoteURL(string $remote): string { |
|
99 | - $remote = str_replace('\\', '/', $remote); |
|
100 | - if ($fileNamePosition = strpos($remote, '/index.php')) { |
|
101 | - $remote = substr($remote, 0, $fileNamePosition); |
|
102 | - } |
|
103 | - $remote = rtrim($remote, '/'); |
|
86 | + /** |
|
87 | + * Strips away a potential file names and trailing slashes: |
|
88 | + * - http://localhost |
|
89 | + * - http://localhost/ |
|
90 | + * - http://localhost/index.php |
|
91 | + * - http://localhost/index.php/s/{shareToken} |
|
92 | + * |
|
93 | + * all return: http://localhost |
|
94 | + * |
|
95 | + * @param string $remote |
|
96 | + * @return string |
|
97 | + */ |
|
98 | + protected function fixRemoteURL(string $remote): string { |
|
99 | + $remote = str_replace('\\', '/', $remote); |
|
100 | + if ($fileNamePosition = strpos($remote, '/index.php')) { |
|
101 | + $remote = substr($remote, 0, $fileNamePosition); |
|
102 | + } |
|
103 | + $remote = rtrim($remote, '/'); |
|
104 | 104 | |
105 | - return $remote; |
|
106 | - } |
|
105 | + return $remote; |
|
106 | + } |
|
107 | 107 | |
108 | - /** |
|
109 | - * @param string $cloudId |
|
110 | - * @return bool |
|
111 | - */ |
|
112 | - public function isValidCloudId(string $cloudId): bool { |
|
113 | - return strpos($cloudId, '@') !== false; |
|
114 | - } |
|
108 | + /** |
|
109 | + * @param string $cloudId |
|
110 | + * @return bool |
|
111 | + */ |
|
112 | + public function isValidCloudId(string $cloudId): bool { |
|
113 | + return strpos($cloudId, '@') !== false; |
|
114 | + } |
|
115 | 115 | } |
@@ -27,54 +27,54 @@ |
||
27 | 27 | use OCP\Federation\ICloudId; |
28 | 28 | |
29 | 29 | class CloudId implements ICloudId { |
30 | - /** @var string */ |
|
31 | - private $id; |
|
32 | - /** @var string */ |
|
33 | - private $user; |
|
34 | - /** @var string */ |
|
35 | - private $remote; |
|
30 | + /** @var string */ |
|
31 | + private $id; |
|
32 | + /** @var string */ |
|
33 | + private $user; |
|
34 | + /** @var string */ |
|
35 | + private $remote; |
|
36 | 36 | |
37 | - /** |
|
38 | - * CloudId constructor. |
|
39 | - * |
|
40 | - * @param string $id |
|
41 | - * @param string $user |
|
42 | - * @param string $remote |
|
43 | - */ |
|
44 | - public function __construct(string $id, string $user, string $remote) { |
|
45 | - $this->id = $id; |
|
46 | - $this->user = $user; |
|
47 | - $this->remote = $remote; |
|
48 | - } |
|
37 | + /** |
|
38 | + * CloudId constructor. |
|
39 | + * |
|
40 | + * @param string $id |
|
41 | + * @param string $user |
|
42 | + * @param string $remote |
|
43 | + */ |
|
44 | + public function __construct(string $id, string $user, string $remote) { |
|
45 | + $this->id = $id; |
|
46 | + $this->user = $user; |
|
47 | + $this->remote = $remote; |
|
48 | + } |
|
49 | 49 | |
50 | - /** |
|
51 | - * The full remote cloud id |
|
52 | - * |
|
53 | - * @return string |
|
54 | - */ |
|
55 | - public function getId(): string { |
|
56 | - return $this->id; |
|
57 | - } |
|
50 | + /** |
|
51 | + * The full remote cloud id |
|
52 | + * |
|
53 | + * @return string |
|
54 | + */ |
|
55 | + public function getId(): string { |
|
56 | + return $this->id; |
|
57 | + } |
|
58 | 58 | |
59 | - public function getDisplayId(): string { |
|
60 | - return str_replace('https://', '', str_replace('http://', '', $this->getId())); |
|
61 | - } |
|
59 | + public function getDisplayId(): string { |
|
60 | + return str_replace('https://', '', str_replace('http://', '', $this->getId())); |
|
61 | + } |
|
62 | 62 | |
63 | - /** |
|
64 | - * The username on the remote server |
|
65 | - * |
|
66 | - * @return string |
|
67 | - */ |
|
68 | - public function getUser(): string { |
|
69 | - return $this->user; |
|
70 | - } |
|
63 | + /** |
|
64 | + * The username on the remote server |
|
65 | + * |
|
66 | + * @return string |
|
67 | + */ |
|
68 | + public function getUser(): string { |
|
69 | + return $this->user; |
|
70 | + } |
|
71 | 71 | |
72 | - /** |
|
73 | - * The base address of the remote server |
|
74 | - * |
|
75 | - * @return string |
|
76 | - */ |
|
77 | - public function getRemote(): string { |
|
78 | - return $this->remote; |
|
79 | - } |
|
72 | + /** |
|
73 | + * The base address of the remote server |
|
74 | + * |
|
75 | + * @return string |
|
76 | + */ |
|
77 | + public function getRemote(): string { |
|
78 | + return $this->remote; |
|
79 | + } |
|
80 | 80 | } |
@@ -32,178 +32,178 @@ |
||
32 | 32 | */ |
33 | 33 | interface IClient { |
34 | 34 | |
35 | - /** |
|
36 | - * Sends a GET request |
|
37 | - * @param string $uri |
|
38 | - * @param array $options Array such as |
|
39 | - * 'query' => [ |
|
40 | - * 'field' => 'abc', |
|
41 | - * 'other_field' => '123', |
|
42 | - * 'file_name' => fopen('/path/to/file', 'r'), |
|
43 | - * ], |
|
44 | - * 'headers' => [ |
|
45 | - * 'foo' => 'bar', |
|
46 | - * ], |
|
47 | - * 'cookies' => [' |
|
48 | - * 'foo' => 'bar', |
|
49 | - * ], |
|
50 | - * 'allow_redirects' => [ |
|
51 | - * 'max' => 10, // allow at most 10 redirects. |
|
52 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
53 | - * 'referer' => true, // add a Referer header |
|
54 | - * 'protocols' => ['https'] // only allow https URLs |
|
55 | - * ], |
|
56 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
57 | - * 'verify' => true, // bool or string to CA file |
|
58 | - * 'debug' => true, |
|
59 | - * @return IResponse |
|
60 | - * @throws \Exception If the request could not get completed |
|
61 | - * @since 8.1.0 |
|
62 | - */ |
|
63 | - public function get(string $uri, array $options = []): IResponse; |
|
35 | + /** |
|
36 | + * Sends a GET request |
|
37 | + * @param string $uri |
|
38 | + * @param array $options Array such as |
|
39 | + * 'query' => [ |
|
40 | + * 'field' => 'abc', |
|
41 | + * 'other_field' => '123', |
|
42 | + * 'file_name' => fopen('/path/to/file', 'r'), |
|
43 | + * ], |
|
44 | + * 'headers' => [ |
|
45 | + * 'foo' => 'bar', |
|
46 | + * ], |
|
47 | + * 'cookies' => [' |
|
48 | + * 'foo' => 'bar', |
|
49 | + * ], |
|
50 | + * 'allow_redirects' => [ |
|
51 | + * 'max' => 10, // allow at most 10 redirects. |
|
52 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
53 | + * 'referer' => true, // add a Referer header |
|
54 | + * 'protocols' => ['https'] // only allow https URLs |
|
55 | + * ], |
|
56 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
57 | + * 'verify' => true, // bool or string to CA file |
|
58 | + * 'debug' => true, |
|
59 | + * @return IResponse |
|
60 | + * @throws \Exception If the request could not get completed |
|
61 | + * @since 8.1.0 |
|
62 | + */ |
|
63 | + public function get(string $uri, array $options = []): IResponse; |
|
64 | 64 | |
65 | - /** |
|
66 | - * Sends a HEAD request |
|
67 | - * @param string $uri |
|
68 | - * @param array $options Array such as |
|
69 | - * 'headers' => [ |
|
70 | - * 'foo' => 'bar', |
|
71 | - * ], |
|
72 | - * 'cookies' => [' |
|
73 | - * 'foo' => 'bar', |
|
74 | - * ], |
|
75 | - * 'allow_redirects' => [ |
|
76 | - * 'max' => 10, // allow at most 10 redirects. |
|
77 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
78 | - * 'referer' => true, // add a Referer header |
|
79 | - * 'protocols' => ['https'] // only allow https URLs |
|
80 | - * ], |
|
81 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
82 | - * 'verify' => true, // bool or string to CA file |
|
83 | - * 'debug' => true, |
|
84 | - * @return IResponse |
|
85 | - * @throws \Exception If the request could not get completed |
|
86 | - * @since 8.1.0 |
|
87 | - */ |
|
88 | - public function head(string $uri, array $options = []): IResponse; |
|
65 | + /** |
|
66 | + * Sends a HEAD request |
|
67 | + * @param string $uri |
|
68 | + * @param array $options Array such as |
|
69 | + * 'headers' => [ |
|
70 | + * 'foo' => 'bar', |
|
71 | + * ], |
|
72 | + * 'cookies' => [' |
|
73 | + * 'foo' => 'bar', |
|
74 | + * ], |
|
75 | + * 'allow_redirects' => [ |
|
76 | + * 'max' => 10, // allow at most 10 redirects. |
|
77 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
78 | + * 'referer' => true, // add a Referer header |
|
79 | + * 'protocols' => ['https'] // only allow https URLs |
|
80 | + * ], |
|
81 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
82 | + * 'verify' => true, // bool or string to CA file |
|
83 | + * 'debug' => true, |
|
84 | + * @return IResponse |
|
85 | + * @throws \Exception If the request could not get completed |
|
86 | + * @since 8.1.0 |
|
87 | + */ |
|
88 | + public function head(string $uri, array $options = []): IResponse; |
|
89 | 89 | |
90 | - /** |
|
91 | - * Sends a POST request |
|
92 | - * @param string $uri |
|
93 | - * @param array $options Array such as |
|
94 | - * 'body' => [ |
|
95 | - * 'field' => 'abc', |
|
96 | - * 'other_field' => '123', |
|
97 | - * 'file_name' => fopen('/path/to/file', 'r'), |
|
98 | - * ], |
|
99 | - * 'headers' => [ |
|
100 | - * 'foo' => 'bar', |
|
101 | - * ], |
|
102 | - * 'cookies' => [' |
|
103 | - * 'foo' => 'bar', |
|
104 | - * ], |
|
105 | - * 'allow_redirects' => [ |
|
106 | - * 'max' => 10, // allow at most 10 redirects. |
|
107 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
108 | - * 'referer' => true, // add a Referer header |
|
109 | - * 'protocols' => ['https'] // only allow https URLs |
|
110 | - * ], |
|
111 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
112 | - * 'verify' => true, // bool or string to CA file |
|
113 | - * 'debug' => true, |
|
114 | - * @return IResponse |
|
115 | - * @throws \Exception If the request could not get completed |
|
116 | - * @since 8.1.0 |
|
117 | - */ |
|
118 | - public function post(string $uri, array $options = []): IResponse; |
|
90 | + /** |
|
91 | + * Sends a POST request |
|
92 | + * @param string $uri |
|
93 | + * @param array $options Array such as |
|
94 | + * 'body' => [ |
|
95 | + * 'field' => 'abc', |
|
96 | + * 'other_field' => '123', |
|
97 | + * 'file_name' => fopen('/path/to/file', 'r'), |
|
98 | + * ], |
|
99 | + * 'headers' => [ |
|
100 | + * 'foo' => 'bar', |
|
101 | + * ], |
|
102 | + * 'cookies' => [' |
|
103 | + * 'foo' => 'bar', |
|
104 | + * ], |
|
105 | + * 'allow_redirects' => [ |
|
106 | + * 'max' => 10, // allow at most 10 redirects. |
|
107 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
108 | + * 'referer' => true, // add a Referer header |
|
109 | + * 'protocols' => ['https'] // only allow https URLs |
|
110 | + * ], |
|
111 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
112 | + * 'verify' => true, // bool or string to CA file |
|
113 | + * 'debug' => true, |
|
114 | + * @return IResponse |
|
115 | + * @throws \Exception If the request could not get completed |
|
116 | + * @since 8.1.0 |
|
117 | + */ |
|
118 | + public function post(string $uri, array $options = []): IResponse; |
|
119 | 119 | |
120 | - /** |
|
121 | - * Sends a PUT request |
|
122 | - * @param string $uri |
|
123 | - * @param array $options Array such as |
|
124 | - * 'body' => [ |
|
125 | - * 'field' => 'abc', |
|
126 | - * 'other_field' => '123', |
|
127 | - * 'file_name' => fopen('/path/to/file', 'r'), |
|
128 | - * ], |
|
129 | - * 'headers' => [ |
|
130 | - * 'foo' => 'bar', |
|
131 | - * ], |
|
132 | - * 'cookies' => [' |
|
133 | - * 'foo' => 'bar', |
|
134 | - * ], |
|
135 | - * 'allow_redirects' => [ |
|
136 | - * 'max' => 10, // allow at most 10 redirects. |
|
137 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
138 | - * 'referer' => true, // add a Referer header |
|
139 | - * 'protocols' => ['https'] // only allow https URLs |
|
140 | - * ], |
|
141 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
142 | - * 'verify' => true, // bool or string to CA file |
|
143 | - * 'debug' => true, |
|
144 | - * @return IResponse |
|
145 | - * @throws \Exception If the request could not get completed |
|
146 | - * @since 8.1.0 |
|
147 | - */ |
|
148 | - public function put(string $uri, array $options = []): IResponse; |
|
120 | + /** |
|
121 | + * Sends a PUT request |
|
122 | + * @param string $uri |
|
123 | + * @param array $options Array such as |
|
124 | + * 'body' => [ |
|
125 | + * 'field' => 'abc', |
|
126 | + * 'other_field' => '123', |
|
127 | + * 'file_name' => fopen('/path/to/file', 'r'), |
|
128 | + * ], |
|
129 | + * 'headers' => [ |
|
130 | + * 'foo' => 'bar', |
|
131 | + * ], |
|
132 | + * 'cookies' => [' |
|
133 | + * 'foo' => 'bar', |
|
134 | + * ], |
|
135 | + * 'allow_redirects' => [ |
|
136 | + * 'max' => 10, // allow at most 10 redirects. |
|
137 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
138 | + * 'referer' => true, // add a Referer header |
|
139 | + * 'protocols' => ['https'] // only allow https URLs |
|
140 | + * ], |
|
141 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
142 | + * 'verify' => true, // bool or string to CA file |
|
143 | + * 'debug' => true, |
|
144 | + * @return IResponse |
|
145 | + * @throws \Exception If the request could not get completed |
|
146 | + * @since 8.1.0 |
|
147 | + */ |
|
148 | + public function put(string $uri, array $options = []): IResponse; |
|
149 | 149 | |
150 | - /** |
|
151 | - * Sends a DELETE request |
|
152 | - * @param string $uri |
|
153 | - * @param array $options Array such as |
|
154 | - * 'body' => [ |
|
155 | - * 'field' => 'abc', |
|
156 | - * 'other_field' => '123', |
|
157 | - * 'file_name' => fopen('/path/to/file', 'r'), |
|
158 | - * ], |
|
159 | - * 'headers' => [ |
|
160 | - * 'foo' => 'bar', |
|
161 | - * ], |
|
162 | - * 'cookies' => [' |
|
163 | - * 'foo' => 'bar', |
|
164 | - * ], |
|
165 | - * 'allow_redirects' => [ |
|
166 | - * 'max' => 10, // allow at most 10 redirects. |
|
167 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
168 | - * 'referer' => true, // add a Referer header |
|
169 | - * 'protocols' => ['https'] // only allow https URLs |
|
170 | - * ], |
|
171 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
172 | - * 'verify' => true, // bool or string to CA file |
|
173 | - * 'debug' => true, |
|
174 | - * @return IResponse |
|
175 | - * @throws \Exception If the request could not get completed |
|
176 | - * @since 8.1.0 |
|
177 | - */ |
|
178 | - public function delete(string $uri, array $options = []): IResponse; |
|
150 | + /** |
|
151 | + * Sends a DELETE request |
|
152 | + * @param string $uri |
|
153 | + * @param array $options Array such as |
|
154 | + * 'body' => [ |
|
155 | + * 'field' => 'abc', |
|
156 | + * 'other_field' => '123', |
|
157 | + * 'file_name' => fopen('/path/to/file', 'r'), |
|
158 | + * ], |
|
159 | + * 'headers' => [ |
|
160 | + * 'foo' => 'bar', |
|
161 | + * ], |
|
162 | + * 'cookies' => [' |
|
163 | + * 'foo' => 'bar', |
|
164 | + * ], |
|
165 | + * 'allow_redirects' => [ |
|
166 | + * 'max' => 10, // allow at most 10 redirects. |
|
167 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
168 | + * 'referer' => true, // add a Referer header |
|
169 | + * 'protocols' => ['https'] // only allow https URLs |
|
170 | + * ], |
|
171 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
172 | + * 'verify' => true, // bool or string to CA file |
|
173 | + * 'debug' => true, |
|
174 | + * @return IResponse |
|
175 | + * @throws \Exception If the request could not get completed |
|
176 | + * @since 8.1.0 |
|
177 | + */ |
|
178 | + public function delete(string $uri, array $options = []): IResponse; |
|
179 | 179 | |
180 | - /** |
|
181 | - * Sends a options request |
|
182 | - * @param string $uri |
|
183 | - * @param array $options Array such as |
|
184 | - * 'body' => [ |
|
185 | - * 'field' => 'abc', |
|
186 | - * 'other_field' => '123', |
|
187 | - * 'file_name' => fopen('/path/to/file', 'r'), |
|
188 | - * ], |
|
189 | - * 'headers' => [ |
|
190 | - * 'foo' => 'bar', |
|
191 | - * ], |
|
192 | - * 'cookies' => [' |
|
193 | - * 'foo' => 'bar', |
|
194 | - * ], |
|
195 | - * 'allow_redirects' => [ |
|
196 | - * 'max' => 10, // allow at most 10 redirects. |
|
197 | - * 'strict' => true, // use "strict" RFC compliant redirects. |
|
198 | - * 'referer' => true, // add a Referer header |
|
199 | - * 'protocols' => ['https'] // only allow https URLs |
|
200 | - * ], |
|
201 | - * 'save_to' => '/path/to/file', // save to a file or a stream |
|
202 | - * 'verify' => true, // bool or string to CA file |
|
203 | - * 'debug' => true, |
|
204 | - * @return IResponse |
|
205 | - * @throws \Exception If the request could not get completed |
|
206 | - * @since 8.1.0 |
|
207 | - */ |
|
208 | - public function options(string $uri, array $options = []): IResponse; |
|
180 | + /** |
|
181 | + * Sends a options request |
|
182 | + * @param string $uri |
|
183 | + * @param array $options Array such as |
|
184 | + * 'body' => [ |
|
185 | + * 'field' => 'abc', |
|
186 | + * 'other_field' => '123', |
|
187 | + * 'file_name' => fopen('/path/to/file', 'r'), |
|
188 | + * ], |
|
189 | + * 'headers' => [ |
|
190 | + * 'foo' => 'bar', |
|
191 | + * ], |
|
192 | + * 'cookies' => [' |
|
193 | + * 'foo' => 'bar', |
|
194 | + * ], |
|
195 | + * 'allow_redirects' => [ |
|
196 | + * 'max' => 10, // allow at most 10 redirects. |
|
197 | + * 'strict' => true, // use "strict" RFC compliant redirects. |
|
198 | + * 'referer' => true, // add a Referer header |
|
199 | + * 'protocols' => ['https'] // only allow https URLs |
|
200 | + * ], |
|
201 | + * 'save_to' => '/path/to/file', // save to a file or a stream |
|
202 | + * 'verify' => true, // bool or string to CA file |
|
203 | + * 'debug' => true, |
|
204 | + * @return IResponse |
|
205 | + * @throws \Exception If the request could not get completed |
|
206 | + * @since 8.1.0 |
|
207 | + */ |
|
208 | + public function options(string $uri, array $options = []): IResponse; |
|
209 | 209 | } |
@@ -31,9 +31,9 @@ |
||
31 | 31 | * @since 8.1.0 |
32 | 32 | */ |
33 | 33 | interface IClientService { |
34 | - /** |
|
35 | - * @return IClient |
|
36 | - * @since 8.1.0 |
|
37 | - */ |
|
38 | - public function newClient(): IClient; |
|
34 | + /** |
|
35 | + * @return IClient |
|
36 | + * @since 8.1.0 |
|
37 | + */ |
|
38 | + public function newClient(): IClient; |
|
39 | 39 | } |