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
Línea -... Línea 2...
-
 
2
 
-
 
3
declare(strict_types=1);
2
 
4
 
Línea 3... Línea 5...
3
namespace GuzzleHttp\Promise;
5
namespace GuzzleHttp\Promise;
4
 
6
 
5
/**
7
/**
Línea 11... Línea 13...
11
{
13
{
12
    /** @var mixed Rejection reason. */
14
    /** @var mixed Rejection reason. */
13
    private $reason;
15
    private $reason;
Línea 14... Línea 16...
14
 
16
 
15
    /**
17
    /**
16
     * @param mixed  $reason      Rejection reason.
18
     * @param mixed       $reason      Rejection reason.
17
     * @param string $description Optional description
19
     * @param string|null $description Optional description.
18
     */
20
     */
19
    public function __construct($reason, $description = null)
21
    public function __construct($reason, ?string $description = null)
20
    {
22
    {
Línea 21... Línea 23...
21
        $this->reason = $reason;
23
        $this->reason = $reason;
Línea 22... Línea 24...
22
 
24
 
23
        $message = 'The promise was rejected';
25
        $message = 'The promise was rejected';
24
 
26
 
25
        if ($description) {
27
        if ($description) {
26
            $message .= ' with reason: ' . $description;
28
            $message .= ' with reason: '.$description;
27
        } elseif (is_string($reason)
29
        } elseif (is_string($reason)
28
            || (is_object($reason) && method_exists($reason, '__toString'))
30
            || (is_object($reason) && method_exists($reason, '__toString'))
29
        ) {
-
 
30
            $message .= ' with reason: ' . $this->reason;
31
        ) {
31
        } elseif ($reason instanceof \JsonSerializable) {
32
            $message .= ' with reason: '.$this->reason;
Línea 32... Línea 33...
32
            $message .= ' with reason: '
33
        } elseif ($reason instanceof \JsonSerializable) {
33
                . json_encode($this->reason, JSON_PRETTY_PRINT);
34
            $message .= ' with reason: '.json_encode($this->reason, JSON_PRETTY_PRINT);