1 | <?php |
||
10 | class LocalBusiness extends AbstractModel implements \BOTK\ModelInterface |
||
11 | { |
||
12 | protected static $DEFAULT_OPTIONS = array ( |
||
13 | 'businessType' => array( |
||
14 | // additional types as extension of schema:LocalBusiness |
||
15 | 'filter' => FILTER_DEFAULT, |
||
16 | 'flags' => FILTER_FORCE_ARRAY, |
||
17 | ), |
||
18 | 'taxID' => array( |
||
19 | 'filter' => FILTER_CALLBACK, |
||
20 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_TOKEN', |
||
21 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
22 | ), |
||
23 | 'vatID' => array( // italian rules |
||
24 | 'filter' => FILTER_VALIDATE_REGEXP, |
||
25 | 'options' => array('regexp'=>'/^[0-9]{11}$/'), |
||
26 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
27 | ), |
||
28 | 'legalName' => array( |
||
29 | 'filter' => FILTER_CALLBACK, |
||
30 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_ADDRESS', |
||
31 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
32 | ), |
||
33 | 'businessName' => array( |
||
34 | // a schema:alternateName for schema:PostalAddress |
||
35 | 'filter' => FILTER_DEFAULT, |
||
36 | 'flags' => FILTER_FORCE_ARRAY, |
||
37 | ), |
||
38 | 'addressDescription'=> array( // |
||
39 | 'filter' => FILTER_CALLBACK, |
||
40 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_ADDRESS', |
||
41 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
42 | ), |
||
43 | 'addressCountry' => array( |
||
44 | 'default' => 'IT', |
||
45 | 'filter' => FILTER_VALIDATE_REGEXP, |
||
46 | 'options' => array('regexp'=>'/^[A-Z]{2}$/'), |
||
47 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
48 | ), |
||
49 | 'addressLocality' => array( |
||
50 | 'filter' => FILTER_CALLBACK, |
||
51 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_ADDRESS', |
||
52 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
53 | ), |
||
54 | 'addressRegion' => array( |
||
55 | 'filter' => FILTER_CALLBACK, |
||
56 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_ADDRESS', |
||
57 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
58 | ), |
||
59 | 'streetAddress' => array( |
||
60 | 'filter' => FILTER_CALLBACK, |
||
61 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_ADDRESS', |
||
62 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
63 | ), |
||
64 | 'postalCode' => array( // italian rules |
||
65 | 'filter' => FILTER_VALIDATE_REGEXP, |
||
66 | 'options' => array('regexp'=>'/^[0-9]{5}$/'), |
||
67 | 'flags' => FILTER_REQUIRE_SCALAR, |
||
68 | ), |
||
69 | 'telephone' => array( |
||
70 | 'filter' => FILTER_CALLBACK, |
||
71 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE', |
||
72 | 'flags' => FILTER_FORCE_ARRAY, |
||
73 | ), |
||
74 | 'faxNumber' => array( |
||
75 | 'filter' => FILTER_CALLBACK, |
||
76 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_TELEPHONE', |
||
77 | 'flags' => FILTER_FORCE_ARRAY, |
||
78 | ), |
||
79 | 'email' => array( |
||
80 | 'filter' => FILTER_CALLBACK, |
||
81 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_EMAIL', |
||
82 | 'flags' => FILTER_FORCE_ARRAY, |
||
83 | ), |
||
84 | 'lat' => array( |
||
85 | 'filter' => FILTER_CALLBACK, |
||
86 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_GEO', |
||
87 | ), |
||
88 | 'long' => array( |
||
89 | 'filter' => FILTER_CALLBACK, |
||
90 | 'options' => '\BOTK\Filters::FILTER_SANITIZE_GEO', |
||
91 | ), |
||
92 | ); |
||
93 | |||
94 | |||
95 | /** |
||
96 | * Redefine protected constructor to add address description as dynamic property |
||
97 | */ |
||
98 | 13 | protected function __construct(array $data = array(), array $customOptions = array()) |
|
103 | |||
104 | |||
105 | /** |
||
106 | * If not existing, create an address description as a normalized address from following data properties: |
||
107 | * 'addressLocality', |
||
108 | * 'addressRegion', |
||
109 | * 'streetAddress', |
||
110 | * 'postalCode', |
||
111 | */ |
||
112 | 13 | private function addAddressDescription() |
|
133 | |||
134 | |||
135 | 4 | public function asTurtleFragment() |
|
196 | |||
197 | } |