|
| 1 | +<?php |
| 2 | + |
| 3 | +namespace org\nameapi\client\services\riskdetector; |
| 4 | + |
| 5 | +require_once(__DIR__ . '/RiskType.php'); |
| 6 | + |
| 7 | +/** |
| 8 | + * Classification of risks. |
| 9 | + * |
| 10 | + * <p>In some situations the exact classification is difficult. |
| 11 | + * For example a person's name may be from fiction, but also be famous at the same time.</p> |
| 12 | + * |
| 13 | + * |
| 14 | + * Possible values are are listed here. |
| 15 | + * |
| 16 | + * |
| 17 | + * RANDOM_TYPING |
| 18 | + * This kind of input is often used to quickly pass mandatory fields in a form. |
| 19 | + * Example: "asdf asdf". |
| 20 | + * |
| 21 | + * |
| 22 | + * PLACEHOLDER |
| 23 | + * Examples: |
| 24 | + * For person name: "John Doe". |
| 25 | + * For person title: Example: "King Peter" |
| 26 | + * The given name field doesn't contain a given name, but has at least a title. |
| 27 | + * It may, in addition, contain a salutation. |
| 28 | + * For salutation: Example: "Mr. Smith" (Mr. in the given name field). |
| 29 | + * The given name field doesn't contain a given name, but has a salutation. |
| 30 | + * There is no title in it, otherwise PLACEHOLDER_TITLE would be used. |
| 31 | + * For place name: "Anytown" |
| 32 | + * |
| 33 | + * |
| 34 | + * FICTIONAL |
| 35 | + * Examples: |
| 36 | + * For natural person: "James Bond". |
| 37 | + * For legal person: ACME (American Company Making Everything) |
| 38 | + * For place: "Atlantis", "Entenhausen" |
| 39 | + * |
| 40 | + * |
| 41 | + * FAMOUS |
| 42 | + * Examples: |
| 43 | + * For natural person: "Barak Obama". |
| 44 | + * |
| 45 | + * |
| 46 | + * HUMOROUS |
| 47 | + * For natural person: "Sandy Beach". |
| 48 | + * Place example: "Timbuckthree" |
| 49 | + * |
| 50 | + * |
| 51 | + * INVALID |
| 52 | + * This includes multiple types of invalid form input. |
| 53 | + * Refusing input: |
| 54 | + * Example: "None of your business" |
| 55 | + * Placeholder nouns: "Someone", "Somebody else", "Somewhere", "Nowhere" |
| 56 | + * Repeating the form fields: |
| 57 | + * Example for person name: "firstname lastname" |
| 58 | + * Examples for street: "Street" |
| 59 | + * Vulgar language, swearing |
| 60 | + * Examples: "fuck off" |
| 61 | + * |
| 62 | + * |
| 63 | + * STRING_SIMILARITY |
| 64 | + * The given name and surname field are equal or almost equal, or match a certain pattern. |
| 65 | + * Example: "John" / "John" |
| 66 | + * The risk score is culture adjusted. In some cultures such names do exist, however, a risk is still raised. |
| 67 | + * |
| 68 | + * |
| 69 | + * OTHER |
| 70 | + * Everything that does not fit into any of the other categories. |
| 71 | + * |
| 72 | + */ |
| 73 | +final class FakeRiskType extends RiskType { |
| 74 | + |
| 75 | + /** |
| 76 | + * @var string $value |
| 77 | + */ |
| 78 | + private $value = null; |
| 79 | + |
| 80 | + public function __construct($value) { |
| 81 | + if ($value!=='RANDOM_TYPING' && $value!=='PLACEHOLDER' && $value!=='FICTIONAL' && $value!=='FAMOUS' && $value!=='HUMOROUS' && $value!=='INVALID' && $value!=='OTHER') { |
| 82 | + throw new \Exception('Invalid value for RiskType: '.$value.'!'); |
| 83 | + } |
| 84 | + $this->value = $value; |
| 85 | + } |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | + public function __toString() { |
| 90 | + return $this->value; |
| 91 | + } |
| 92 | + |
| 93 | +} |
| 94 | + |
0 commit comments