ReviewStatus.php
1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
<?php
namespace WPML\TM\ATE\Review;
use WPML\Collect\Support\Traits\Macroable;
use WPML\FP\Fns;
use WPML\FP\Logic;
use WPML\FP\Lst;
use WPML\FP\Obj;
use function WPML\FP\curryN;
use function WPML\FP\pipe;
/**
* Class ReviewStatus
* @package WPML\TM\ATE\Review
*
* @method static callable|bool doesJobNeedReview( ...$job ) - Curried :: \stdClass->bool
*/
class ReviewStatus {
use Macroable;
const NEEDS_REVIEW = 'NEEDS_REVIEW';
const EDITING = 'EDITING';
const ACCEPTED = 'ACCEPTED';
public static function init() {
self::macro( 'doesJobNeedReview', curryN( 1, Logic::ifElse(
Fns::identity(),
pipe( Obj::prop( 'review_status' ), self::needsReview() ),
Fns::always(false)
) ));
}
/**
* @template A as string|curried
* @param A $reviewStatus
*
* @return (A is curried ? callable : bool)
*/
public static function needsReview( $reviewStatus = null ) {
return Lst::includes(
$reviewStatus ?: Fns::__,
[
self::NEEDS_REVIEW,
self::EDITING,
]
);
}
}
ReviewStatus::init();