Settled   A
last analyzed

Complexity

Total Complexity 2

Size/Duplication

Total Lines 22
Duplicated Lines 0 %

Importance

Changes 1
Bugs 0 Features 1
Metric Value
eloc 5
c 1
b 0
f 1
dl 0
loc 22
rs 10
wmc 2

2 Methods

Rating   Name   Duplication   Size   Complexity  
A resolved() 0 4 1
A rejected() 0 4 1
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