-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.php
More file actions
45 lines (23 loc) · 881 Bytes
/
index.php
File metadata and controls
45 lines (23 loc) · 881 Bytes
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
<?php
require_once 'src/None.php';
require_once 'src/Some.php';
require_once 'src/Option.php';
require_once 'src/State.php';
require_once 'src/MatchResponse.php';
$response = Option::from(new State(State::DUPLICATE_TYPE))->map(function (State $state) {
return $state->isDuplicate() ? 409 : 201;
})->getOrElse(200);
var_dump($response);
$response = Option::from([State::LEAD_TYPE, '34324324324324'])->map(function ($tuple) {
list($type, $id) = $tuple;
return $type === State::DUPLICATE_TYPE ? 409 : 201;
})->getOrElse(200);
var_dump($response);
$response = Option::from(null)->map(function ($tuple) {
list($type, $id) = $tuple;
return $type === State::DUPLICATE_TYPE ? 409 : 201;
})->getOrElse(200);
var_dump($response);
$response = MatchResponse::match(Option::from(new State(State::DUPLICATE_TYPE)));
var_dump($response);
Option::from(2);