forked from jgosier/ushahidi_swift
/
StateController.php
95 lines (86 loc) · 2.3 KB
/
StateController.php
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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
<?php
namespace Swiftriver\Core\StateTransition;
/**
* Class providing static strongly typed access to the
* list of alowable states and the transition of states
* of an item of content
*
* @author mg[at]swiftly[dot]org
*/
class StateController
{
/**
* the default state of a content item
* @var int
*/
public static $defaultState = "new_content";
/**
* public list of all states
* @var array
*/
private static $states = array
(
"new_content",
"accurate",
"inaccurate",
"chatter",
"irrelevant"
);
/**
* Given a content item, this function marks it as ACCURATE
* @param \Swiftriver\Core\ObjectModel\Content $content
*/
public static function MarkContentAcurate($content)
{
$content->state = "accurate";
return $content;
}
/**
* Given a content item, this function marks it as INACCURATE
* @param \Swiftriver\Core\ObjectModel\Content $content
*/
public static function MarkContentInaccurate($content)
{
$content->state = "inaccurate";
return $content;
}
/**
* Given a content item, this function marks it as CHATTER
* @param \Swiftriver\Core\ObjectModel\Content $content
*/
public static function MarkContentChatter($content)
{
$content->state = "chatter";
return $content;
}
/**
* Given a content item, this function marks it as IRRELEVANT
* @param \Swiftriver\Core\ObjectModel\Content $content
*/
public static function MarkContentIrrelevant($content)
{
$content->state = "irrelevant";
return $content;
}
/**
* Given a content item, this function marks it as SENT TO USHAHIDI
* @param \Swiftriver\Core\ObjectModel\Content $content
*/
public static function MarkContentAsSentToUshahidi($content)
{
$content->state = "sent_to_ushahidi";
return $content;
}
/**
* Given a string, this function checks if it is a valid reason for
* marking a content item as inaccurate.
*
* @param string $reason
* @return bool
*/
public static function IsValidInacurateReason($reason)
{
return ($reason == "falsehood" || $reason == "inaccuracy" || $reason == "biased");
}
}
?>