Settled::resolved()   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
cc 1
eloc 2
c 1
b 0
f 1
nc 1
nop 1
dl 0
loc 4
rs 10
1
<?php
2
/**
3
 * Settled
4
 * User: moyo
5
 * Date: 15/09/2017
6
 * Time: 10:11 PM
7
 */
8
9
namespace Carno\Promise\Features;
10
11
use Carno\Promise\Promise;
12
use Carno\Promise\Promised;
13
use Throwable;
14
15
trait Settled
16
{
17
    /**
18
     * @param mixed ...$data
19
     * @return Promised
20
     */
21
    public static function resolved(...$data)
22
    {
23
        return new Promise(static function (Promised $p) use ($data) {
24
            $p->resolve(...$data);
25
        });
26
    }
27
28
    /**
29
     * @param mixed ...$data
30
     * @return Promised
31
     * @throws Throwable
32
     */
33
    public static function rejected(...$data)
34
    {
35
        return new Promise(static function (Promised $p) use ($data) {
36
            $p->reject(...$data);
37
        });
38
    }
39
}
40