Proyectos de Subversion Moodle

Rev

Rev 1 | Mostrar el archivo completo | | | Autoría | Ultima modificación | Ver Log |

Rev 1 Rev 1441
Línea 1... Línea 1...
1
<?php
1
<?php
2
namespace Aws;
2
namespace Aws;
Línea 3... Línea 3...
3
 
3
 
4
use Aws\Exception\AwsException;
4
use Aws\Exception\AwsException;
-
 
5
use GuzzleHttp\Promise\Coroutine;
5
use GuzzleHttp\Promise\Coroutine;
6
use GuzzleHttp\Promise\PromiseInterface;
6
use GuzzleHttp\Promise\PromisorInterface;
7
use GuzzleHttp\Promise\PromisorInterface;
Línea 7... Línea 8...
7
use GuzzleHttp\Promise\RejectedPromise;
8
use GuzzleHttp\Promise\RejectedPromise;
8
 
9
 
Línea 82... Línea 83...
82
        if ($this->config['before'] && !is_callable($this->config['before'])) {
83
        if ($this->config['before'] && !is_callable($this->config['before'])) {
83
            throw new \InvalidArgumentException(
84
            throw new \InvalidArgumentException(
84
                'The provided "before" callback is not callable.'
85
                'The provided "before" callback is not callable.'
85
            );
86
            );
86
        }
87
        }
-
 
88
        MetricsBuilder::appendMetricsCaptureMiddleware(
-
 
89
            $this->client->getHandlerList(),
-
 
90
            MetricsBuilder::WAITER
-
 
91
        );
87
    }
92
    }
Línea 88... Línea 93...
88
 
93
 
89
    /**
94
    /**
90
     * @return Coroutine
95
     * @return Coroutine
91
     */
96
     */
92
    public function promise()
97
    public function promise(): PromiseInterface
93
    {
98
    {
94
        return Coroutine::of(function () {
99
        return Coroutine::of(function () {
95
            $name = $this->config['operation'];
100
            $name = $this->config['operation'];
96
            for ($state = 'retry', $attempt = 1; $state === 'retry'; $attempt++) {
101
            for ($state = 'retry', $attempt = 1; $state === 'retry'; $attempt++) {
Línea 183... Línea 188...
183
     *
188
     *
184
     * @return bool
189
     * @return bool
185
     */
190
     */
186
    private function matchesPath($result, array $acceptor)
191
    private function matchesPath($result, array $acceptor)
187
    {
192
    {
188
        return !($result instanceof ResultInterface)
193
        return $result instanceof ResultInterface
189
            ? false
-
 
190
            : $acceptor['expected'] == $result->search($acceptor['argument']);
194
            && $acceptor['expected'] === $result->search($acceptor['argument']);
191
    }
195
    }
Línea 192... Línea 196...
192
 
196
 
193
    /**
197
    /**
194
     * @param Result $result   Result or exception.
198
     * @param Result $result   Result or exception.
Línea 201... Línea 205...
201
        if (!($result instanceof ResultInterface)) {
205
        if (!($result instanceof ResultInterface)) {
202
            return false;
206
            return false;
203
        }
207
        }
Línea 204... Línea 208...
204
 
208
 
-
 
209
        $actuals = $result->search($acceptor['argument']) ?: [];
-
 
210
        // If is empty or not evaluates to an array it must return false.
-
 
211
        if (empty($actuals) || !is_array($actuals)) {
-
 
212
            return false;
-
 
213
        }
205
        $actuals = $result->search($acceptor['argument']) ?: [];
214
 
206
        foreach ($actuals as $actual) {
215
        foreach ($actuals as $actual) {
207
            if ($actual != $acceptor['expected']) {
216
            if ($actual != $acceptor['expected']) {
208
                return false;
217
                return false;
209
            }
218
            }
Línea 223... Línea 232...
223
        if (!($result instanceof ResultInterface)) {
232
        if (!($result instanceof ResultInterface)) {
224
            return false;
233
            return false;
225
        }
234
        }
Línea 226... Línea 235...
226
 
235
 
-
 
236
        $actuals = $result->search($acceptor['argument']) ?: [];
-
 
237
        // If is empty or not evaluates to an array it must return false.
-
 
238
        if (empty($actuals) || !is_array($actuals)) {
-
 
239
            return false;
-
 
240
        }
227
        $actuals = $result->search($acceptor['argument']) ?: [];
241
 
228
        return in_array($acceptor['expected'], $actuals);
242
        return in_array($acceptor['expected'], $actuals);
Línea 229... Línea 243...
229
    }
243
    }
230
 
244
 
Línea 253... Línea 267...
253
     *
267
     *
254
     * @return bool
268
     * @return bool
255
     */
269
     */
256
    private function matchesError($result, array $acceptor)
270
    private function matchesError($result, array $acceptor)
257
    {
271
    {
-
 
272
        // If expected is true then the $result should be an instance of
-
 
273
        // AwsException, otherwise it should not.
-
 
274
        if (isset($acceptor['expected']) && is_bool($acceptor['expected'])) {
-
 
275
            return $acceptor['expected'] === ($result instanceof AwsException);
-
 
276
        }
-
 
277
 
258
        if ($result instanceof AwsException) {
278
        if ($result instanceof AwsException) {
259
            return $result->isConnectionError()
279
            return $result->isConnectionError()
260
                || $result->getAwsErrorCode() == $acceptor['expected'];
280
                || $result->getAwsErrorCode() == $acceptor['expected'];
261
        }
281
        }