@@ -58,6 +58,7 @@ |
||
58 | 58 | |
59 | 59 | /** |
60 | 60 | * Normalize email |
61 | + * @param string $value |
|
61 | 62 | */ |
62 | 63 | static function normalizeEmail($value) |
63 | 64 | { |
@@ -7,91 +7,91 @@ |
||
7 | 7 | */ |
8 | 8 | class Filters { |
9 | 9 | |
10 | - /** |
|
11 | - * uppercase, no trailing and ending blancs, no multiple spaces, no "strange" strings, no blanks after dot., a single blanc after comma |
|
12 | - */ |
|
13 | - static function normalizeAddress($value) |
|
14 | - { |
|
15 | - $value = filter_var($value, FILTER_SANITIZE_STRING); // no "strange" strings |
|
16 | - $value = preg_replace('/\s*([,;])/', '$1 ', $value); // a single blanc after comma and semicolon, no space before |
|
17 | - $value = preg_replace('/\-/', ' - ', $value); // a single blanc after and before dash |
|
18 | - $value = preg_replace('/\s*\.\s*/', '.', $value); // no blanks before and after dot |
|
19 | - $value = preg_replace('/[\s]{1,}/', ' ', $value); // no multiple spaces, |
|
20 | - $value = preg_replace('/,\s,\s/', ', ', $value); // remove multiple comma |
|
21 | - $value = preg_replace('/;\s;\s/', '; ', $value); // remove multiple semicolon |
|
22 | - $value = preg_replace('/\-\s\-\s/', '- ', $value); // remove multiple dash |
|
23 | - $value = preg_replace('/^\s*[\,\;]/', '', $value); // remove comma and semicolon at start |
|
24 | - $value = trim($value); // no trailing and ending blancs |
|
25 | - return mb_strtoupper($value,'UTF-8'); // uppercase |
|
26 | - } |
|
10 | + /** |
|
11 | + * uppercase, no trailing and ending blancs, no multiple spaces, no "strange" strings, no blanks after dot., a single blanc after comma |
|
12 | + */ |
|
13 | + static function normalizeAddress($value) |
|
14 | + { |
|
15 | + $value = filter_var($value, FILTER_SANITIZE_STRING); // no "strange" strings |
|
16 | + $value = preg_replace('/\s*([,;])/', '$1 ', $value); // a single blanc after comma and semicolon, no space before |
|
17 | + $value = preg_replace('/\-/', ' - ', $value); // a single blanc after and before dash |
|
18 | + $value = preg_replace('/\s*\.\s*/', '.', $value); // no blanks before and after dot |
|
19 | + $value = preg_replace('/[\s]{1,}/', ' ', $value); // no multiple spaces, |
|
20 | + $value = preg_replace('/,\s,\s/', ', ', $value); // remove multiple comma |
|
21 | + $value = preg_replace('/;\s;\s/', '; ', $value); // remove multiple semicolon |
|
22 | + $value = preg_replace('/\-\s\-\s/', '- ', $value); // remove multiple dash |
|
23 | + $value = preg_replace('/^\s*[\,\;]/', '', $value); // remove comma and semicolon at start |
|
24 | + $value = trim($value); // no trailing and ending blancs |
|
25 | + return mb_strtoupper($value,'UTF-8'); // uppercase |
|
26 | + } |
|
27 | 27 | |
28 | 28 | |
29 | - static function normalizeToken($value) |
|
30 | - { |
|
31 | - $value = preg_replace('/[^\w]/', '', $value); |
|
32 | - return strtoupper($value); |
|
33 | - } |
|
29 | + static function normalizeToken($value) |
|
30 | + { |
|
31 | + $value = preg_replace('/[^\w]/', '', $value); |
|
32 | + return strtoupper($value); |
|
33 | + } |
|
34 | 34 | |
35 | 35 | |
36 | - /** |
|
37 | - * Normalize an italian telephone number |
|
38 | - */ |
|
39 | - static function normalizeItTelephone($value) |
|
40 | - { |
|
41 | - $value = preg_replace('/^[^0-9\+]+/', '', $value); // remove all from beginning execept numbers and + |
|
42 | - $value = preg_replace('/^\+39/', '', $value); // remove +39 prefix |
|
43 | - $value = preg_replace('/^0039/', '', $value); // remove 0039 prefix |
|
44 | - $value = preg_replace('/[\s\(\)]+/', '', $value); // remove all blanks and parenthesis |
|
36 | + /** |
|
37 | + * Normalize an italian telephone number |
|
38 | + */ |
|
39 | + static function normalizeItTelephone($value) |
|
40 | + { |
|
41 | + $value = preg_replace('/^[^0-9\+]+/', '', $value); // remove all from beginning execept numbers and + |
|
42 | + $value = preg_replace('/^\+39/', '', $value); // remove +39 prefix |
|
43 | + $value = preg_replace('/^0039/', '', $value); // remove 0039 prefix |
|
44 | + $value = preg_replace('/[\s\(\)]+/', '', $value); // remove all blanks and parenthesis |
|
45 | 45 | |
46 | - // separate number from extensions (if any) |
|
47 | - if( preg_match('/([0-9]+)(.*)/', $value, $matches)){ |
|
48 | - $value = $matches[1]; |
|
49 | - $extension = preg_replace('/[^0-9]/', '', $matches[2]);; |
|
50 | - if($extension){ |
|
51 | - $value .= " [$extension]"; |
|
52 | - } |
|
53 | - } |
|
46 | + // separate number from extensions (if any) |
|
47 | + if( preg_match('/([0-9]+)(.*)/', $value, $matches)){ |
|
48 | + $value = $matches[1]; |
|
49 | + $extension = preg_replace('/[^0-9]/', '', $matches[2]);; |
|
50 | + if($extension){ |
|
51 | + $value .= " [$extension]"; |
|
52 | + } |
|
53 | + } |
|
54 | 54 | |
55 | - return $value; |
|
56 | - } |
|
55 | + return $value; |
|
56 | + } |
|
57 | 57 | |
58 | 58 | |
59 | - /** |
|
60 | - * Normalize email |
|
61 | - */ |
|
62 | - static function normalizeEmail($value) |
|
63 | - { |
|
64 | - $value = filter_var($value, FILTER_VALIDATE_EMAIL); |
|
65 | - return strtoupper($value); |
|
66 | - } |
|
59 | + /** |
|
60 | + * Normalize email |
|
61 | + */ |
|
62 | + static function normalizeEmail($value) |
|
63 | + { |
|
64 | + $value = filter_var($value, FILTER_VALIDATE_EMAIL); |
|
65 | + return strtoupper($value); |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - /** |
|
70 | - * Create a normalizzed addres from a propery list. |
|
71 | - * Property list can contain follwin fields: |
|
72 | - * 'addressCountry', |
|
73 | - * 'addressLocality', |
|
74 | - * 'addressRegion', |
|
75 | - * 'streetAddress', |
|
76 | - * 'postalCode', |
|
77 | - */ |
|
78 | - static function buildNormalizedAddress(array $properties) |
|
79 | - { |
|
80 | - extract($properties); |
|
69 | + /** |
|
70 | + * Create a normalizzed addres from a propery list. |
|
71 | + * Property list can contain follwin fields: |
|
72 | + * 'addressCountry', |
|
73 | + * 'addressLocality', |
|
74 | + * 'addressRegion', |
|
75 | + * 'streetAddress', |
|
76 | + * 'postalCode', |
|
77 | + */ |
|
78 | + static function buildNormalizedAddress(array $properties) |
|
79 | + { |
|
80 | + extract($properties); |
|
81 | 81 | |
82 | - // veryfy that at least a minimum set of information are present |
|
83 | - if(empty($streetAddress) || empty($addressCountry) || (empty($addressLocality) && empty($postalCode))){ |
|
84 | - return false; |
|
85 | - } |
|
82 | + // veryfy that at least a minimum set of information are present |
|
83 | + if(empty($streetAddress) || empty($addressCountry) || (empty($addressLocality) && empty($postalCode))){ |
|
84 | + return false; |
|
85 | + } |
|
86 | 86 | |
87 | - $geolabel = "$streetAddress ,"; |
|
88 | - if(!empty($postalCode)) { $geolabel.= " $postalCode";} |
|
89 | - if(!empty($addressLocality)) { $geolabel.= " $addressLocality"; } |
|
90 | - if(!empty($addressRegion)) { $geolabel.= " ($addressRegion)"; } |
|
91 | - $geolabel.= " - $addressCountry"; |
|
87 | + $geolabel = "$streetAddress ,"; |
|
88 | + if(!empty($postalCode)) { $geolabel.= " $postalCode";} |
|
89 | + if(!empty($addressLocality)) { $geolabel.= " $addressLocality"; } |
|
90 | + if(!empty($addressRegion)) { $geolabel.= " ($addressRegion)"; } |
|
91 | + $geolabel.= " - $addressCountry"; |
|
92 | 92 | |
93 | - return self::normalizeAddress($geolabel); |
|
94 | - } |
|
93 | + return self::normalizeAddress($geolabel); |
|
94 | + } |
|
95 | 95 | |
96 | 96 | |
97 | 97 | } |
98 | 98 | \ No newline at end of file |
@@ -12,17 +12,17 @@ discard block |
||
12 | 12 | */ |
13 | 13 | static function normalizeAddress($value) |
14 | 14 | { |
15 | - $value = filter_var($value, FILTER_SANITIZE_STRING); // no "strange" strings |
|
16 | - $value = preg_replace('/\s*([,;])/', '$1 ', $value); // a single blanc after comma and semicolon, no space before |
|
17 | - $value = preg_replace('/\-/', ' - ', $value); // a single blanc after and before dash |
|
18 | - $value = preg_replace('/\s*\.\s*/', '.', $value); // no blanks before and after dot |
|
19 | - $value = preg_replace('/[\s]{1,}/', ' ', $value); // no multiple spaces, |
|
20 | - $value = preg_replace('/,\s,\s/', ', ', $value); // remove multiple comma |
|
21 | - $value = preg_replace('/;\s;\s/', '; ', $value); // remove multiple semicolon |
|
22 | - $value = preg_replace('/\-\s\-\s/', '- ', $value); // remove multiple dash |
|
23 | - $value = preg_replace('/^\s*[\,\;]/', '', $value); // remove comma and semicolon at start |
|
24 | - $value = trim($value); // no trailing and ending blancs |
|
25 | - return mb_strtoupper($value,'UTF-8'); // uppercase |
|
15 | + $value = filter_var($value, FILTER_SANITIZE_STRING); // no "strange" strings |
|
16 | + $value = preg_replace('/\s*([,;])/', '$1 ', $value); // a single blanc after comma and semicolon, no space before |
|
17 | + $value = preg_replace('/\-/', ' - ', $value); // a single blanc after and before dash |
|
18 | + $value = preg_replace('/\s*\.\s*/', '.', $value); // no blanks before and after dot |
|
19 | + $value = preg_replace('/[\s]{1,}/', ' ', $value); // no multiple spaces, |
|
20 | + $value = preg_replace('/,\s,\s/', ', ', $value); // remove multiple comma |
|
21 | + $value = preg_replace('/;\s;\s/', '; ', $value); // remove multiple semicolon |
|
22 | + $value = preg_replace('/\-\s\-\s/', '- ', $value); // remove multiple dash |
|
23 | + $value = preg_replace('/^\s*[\,\;]/', '', $value); // remove comma and semicolon at start |
|
24 | + $value = trim($value); // no trailing and ending blancs |
|
25 | + return mb_strtoupper($value, 'UTF-8'); // uppercase |
|
26 | 26 | } |
27 | 27 | |
28 | 28 | |
@@ -38,16 +38,16 @@ discard block |
||
38 | 38 | */ |
39 | 39 | static function normalizeItTelephone($value) |
40 | 40 | { |
41 | - $value = preg_replace('/^[^0-9\+]+/', '', $value); // remove all from beginning execept numbers and + |
|
42 | - $value = preg_replace('/^\+39/', '', $value); // remove +39 prefix |
|
43 | - $value = preg_replace('/^0039/', '', $value); // remove 0039 prefix |
|
44 | - $value = preg_replace('/[\s\(\)]+/', '', $value); // remove all blanks and parenthesis |
|
41 | + $value = preg_replace('/^[^0-9\+]+/', '', $value); // remove all from beginning execept numbers and + |
|
42 | + $value = preg_replace('/^\+39/', '', $value); // remove +39 prefix |
|
43 | + $value = preg_replace('/^0039/', '', $value); // remove 0039 prefix |
|
44 | + $value = preg_replace('/[\s\(\)]+/', '', $value); // remove all blanks and parenthesis |
|
45 | 45 | |
46 | 46 | // separate number from extensions (if any) |
47 | - if( preg_match('/([0-9]+)(.*)/', $value, $matches)){ |
|
47 | + if (preg_match('/([0-9]+)(.*)/', $value, $matches)) { |
|
48 | 48 | $value = $matches[1]; |
49 | - $extension = preg_replace('/[^0-9]/', '', $matches[2]);; |
|
50 | - if($extension){ |
|
49 | + $extension = preg_replace('/[^0-9]/', '', $matches[2]); ; |
|
50 | + if ($extension) { |
|
51 | 51 | $value .= " [$extension]"; |
52 | 52 | } |
53 | 53 | } |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | static function normalizeEmail($value) |
63 | 63 | { |
64 | - $value = filter_var($value, FILTER_VALIDATE_EMAIL); |
|
64 | + $value = filter_var($value, FILTER_VALIDATE_EMAIL); |
|
65 | 65 | return strtoupper($value); |
66 | 66 | } |
67 | 67 | |
@@ -80,15 +80,15 @@ discard block |
||
80 | 80 | extract($properties); |
81 | 81 | |
82 | 82 | // veryfy that at least a minimum set of information are present |
83 | - if(empty($streetAddress) || empty($addressCountry) || (empty($addressLocality) && empty($postalCode))){ |
|
83 | + if (empty($streetAddress) || empty($addressCountry) || (empty($addressLocality) && empty($postalCode))) { |
|
84 | 84 | return false; |
85 | 85 | } |
86 | 86 | |
87 | 87 | $geolabel = "$streetAddress ,"; |
88 | - if(!empty($postalCode)) { $geolabel.= " $postalCode";} |
|
89 | - if(!empty($addressLocality)) { $geolabel.= " $addressLocality"; } |
|
90 | - if(!empty($addressRegion)) { $geolabel.= " ($addressRegion)"; } |
|
91 | - $geolabel.= " - $addressCountry"; |
|
88 | + if (!empty($postalCode)) { $geolabel .= " $postalCode"; } |
|
89 | + if (!empty($addressLocality)) { $geolabel .= " $addressLocality"; } |
|
90 | + if (!empty($addressRegion)) { $geolabel .= " ($addressRegion)"; } |
|
91 | + $geolabel .= " - $addressCountry"; |
|
92 | 92 | |
93 | 93 | return self::normalizeAddress($geolabel); |
94 | 94 | } |
@@ -12,172 +12,172 @@ |
||
12 | 12 | class LocalBusiness extends AbstractModel implements ModelInterface |
13 | 13 | { |
14 | 14 | |
15 | - static protected $DEFAULT_OPTIONS = array ( |
|
16 | - 'base' => array( |
|
17 | - 'default' => 'http://linkeddata.center/botk/resource/', |
|
18 | - 'filter' => FILTER_SANITIZE_URL, |
|
19 | - ), |
|
20 | - 'uri' => array( |
|
21 | - 'filter' => FILTER_SANITIZE_URL, |
|
22 | - ), |
|
23 | - 'lang' => array( |
|
24 | - 'default' => 'it', |
|
25 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
26 | - 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
27 | - ), |
|
28 | - 'id' => array( |
|
29 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
30 | - 'options' => array('regexp'=>'/^[\w]+$/') |
|
31 | - ), |
|
32 | - 'taxID' => array( |
|
33 | - 'filter' => FILTER_CALLBACK, |
|
34 | - 'options' => '\BOTK\Filters::normalizeToken' |
|
35 | - ), |
|
36 | - 'vatID' => array( // italian rules |
|
37 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
38 | - 'options' => array('regexp'=>'/^[0-9]{11}$/') |
|
39 | - ), |
|
40 | - 'legalName' => array( |
|
41 | - 'filter' => FILTER_CALLBACK, |
|
42 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
43 | - ), |
|
44 | - 'alternateName' => array(), |
|
45 | - 'addressCountry' => array( |
|
46 | - 'default' => 'IT', |
|
47 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
48 | - 'options' => array('regexp'=>'/^[A-Z]{2}$/') |
|
49 | - ), |
|
50 | - 'addressLocality' => array( |
|
51 | - 'filter' => FILTER_CALLBACK, |
|
52 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
53 | - ), |
|
54 | - 'addressRegion' => array( |
|
55 | - 'filter' => FILTER_CALLBACK, |
|
56 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
57 | - ), |
|
58 | - 'streetAddress' => array( |
|
59 | - 'filter' => FILTER_CALLBACK, |
|
60 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
61 | - ), |
|
62 | - 'postalCode' => array( // italian rules |
|
63 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
64 | - 'options' => array('regexp'=>'/^[0-9]{5}$/') |
|
65 | - ), |
|
66 | - 'page' => array( |
|
67 | - 'filter' => FILTER_SANITIZE_URL |
|
68 | - ), |
|
69 | - 'telephone' => array( |
|
70 | - 'filter' => FILTER_CALLBACK, |
|
71 | - 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
72 | - ), |
|
73 | - 'faxNumber' => array( |
|
74 | - 'filter' => FILTER_CALLBACK, |
|
75 | - 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
76 | - ), |
|
77 | - 'email' => array( |
|
78 | - 'filter' => FILTER_CALLBACK, |
|
79 | - 'options' => '\BOTK\Filters::normalizeEmail' |
|
80 | - ), |
|
81 | - 'geoDescription' => array( |
|
82 | - 'filter' => FILTER_CALLBACK, |
|
83 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
84 | - ), |
|
85 | - 'lat' => array( // http://www.regexlib.com/REDetails.aspx?regexp_id=2728 |
|
86 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
87 | - 'options' => array('regexp'=>'/^-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
88 | - ), |
|
89 | - 'long' => array( // http://stackoverflow.com/questions/3518504/regular-expression-for-matching-latitude-longitude-coordinates |
|
90 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
91 | - 'options' => array('regexp'=>'/-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
92 | - ), |
|
93 | - ); |
|
15 | + static protected $DEFAULT_OPTIONS = array ( |
|
16 | + 'base' => array( |
|
17 | + 'default' => 'http://linkeddata.center/botk/resource/', |
|
18 | + 'filter' => FILTER_SANITIZE_URL, |
|
19 | + ), |
|
20 | + 'uri' => array( |
|
21 | + 'filter' => FILTER_SANITIZE_URL, |
|
22 | + ), |
|
23 | + 'lang' => array( |
|
24 | + 'default' => 'it', |
|
25 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
26 | + 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
27 | + ), |
|
28 | + 'id' => array( |
|
29 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
30 | + 'options' => array('regexp'=>'/^[\w]+$/') |
|
31 | + ), |
|
32 | + 'taxID' => array( |
|
33 | + 'filter' => FILTER_CALLBACK, |
|
34 | + 'options' => '\BOTK\Filters::normalizeToken' |
|
35 | + ), |
|
36 | + 'vatID' => array( // italian rules |
|
37 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
38 | + 'options' => array('regexp'=>'/^[0-9]{11}$/') |
|
39 | + ), |
|
40 | + 'legalName' => array( |
|
41 | + 'filter' => FILTER_CALLBACK, |
|
42 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
43 | + ), |
|
44 | + 'alternateName' => array(), |
|
45 | + 'addressCountry' => array( |
|
46 | + 'default' => 'IT', |
|
47 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
48 | + 'options' => array('regexp'=>'/^[A-Z]{2}$/') |
|
49 | + ), |
|
50 | + 'addressLocality' => array( |
|
51 | + 'filter' => FILTER_CALLBACK, |
|
52 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
53 | + ), |
|
54 | + 'addressRegion' => array( |
|
55 | + 'filter' => FILTER_CALLBACK, |
|
56 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
57 | + ), |
|
58 | + 'streetAddress' => array( |
|
59 | + 'filter' => FILTER_CALLBACK, |
|
60 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
61 | + ), |
|
62 | + 'postalCode' => array( // italian rules |
|
63 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
64 | + 'options' => array('regexp'=>'/^[0-9]{5}$/') |
|
65 | + ), |
|
66 | + 'page' => array( |
|
67 | + 'filter' => FILTER_SANITIZE_URL |
|
68 | + ), |
|
69 | + 'telephone' => array( |
|
70 | + 'filter' => FILTER_CALLBACK, |
|
71 | + 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
72 | + ), |
|
73 | + 'faxNumber' => array( |
|
74 | + 'filter' => FILTER_CALLBACK, |
|
75 | + 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
76 | + ), |
|
77 | + 'email' => array( |
|
78 | + 'filter' => FILTER_CALLBACK, |
|
79 | + 'options' => '\BOTK\Filters::normalizeEmail' |
|
80 | + ), |
|
81 | + 'geoDescription' => array( |
|
82 | + 'filter' => FILTER_CALLBACK, |
|
83 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
84 | + ), |
|
85 | + 'lat' => array( // http://www.regexlib.com/REDetails.aspx?regexp_id=2728 |
|
86 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
87 | + 'options' => array('regexp'=>'/^-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
88 | + ), |
|
89 | + 'long' => array( // http://stackoverflow.com/questions/3518504/regular-expression-for-matching-latitude-longitude-coordinates |
|
90 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
91 | + 'options' => array('regexp'=>'/-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
92 | + ), |
|
93 | + ); |
|
94 | 94 | |
95 | 95 | |
96 | - public function asTurtle() |
|
97 | - { |
|
98 | - if(is_null($this->rdf)) { |
|
99 | - $tc =0; |
|
100 | - $rdf=''; |
|
101 | - extract($this->data); |
|
96 | + public function asTurtle() |
|
97 | + { |
|
98 | + if(is_null($this->rdf)) { |
|
99 | + $tc =0; |
|
100 | + $rdf=''; |
|
101 | + extract($this->data); |
|
102 | 102 | |
103 | - // create uris |
|
104 | - $organizationUri = empty($uri)?($base. (empty($id)?uniqid():$id)):$uri; |
|
105 | - $addressUri = $organizationUri.'_address'; |
|
106 | - $placeUri = $organizationUri.'_place'; |
|
107 | - $geoUri = ( !empty($lat) && !empty($long) )?"geo:$lat,$long":($organizationUri.'_geo'); |
|
103 | + // create uris |
|
104 | + $organizationUri = empty($uri)?($base. (empty($id)?uniqid():$id)):$uri; |
|
105 | + $addressUri = $organizationUri.'_address'; |
|
106 | + $placeUri = $organizationUri.'_place'; |
|
107 | + $geoUri = ( !empty($lat) && !empty($long) )?"geo:$lat,$long":($organizationUri.'_geo'); |
|
108 | 108 | |
109 | 109 | |
110 | - // define the minimum condition to skipp the rdf generation |
|
110 | + // define the minimum condition to skipp the rdf generation |
|
111 | 111 | |
112 | - $skippAddress = empty($alternateName) && |
|
113 | - empty($addressLocality) && |
|
114 | - empty($streetAddress) && |
|
115 | - empty($postalCode) && |
|
116 | - empty($page) && |
|
117 | - empty($telephone) && |
|
118 | - empty($faxNumber) && |
|
119 | - empty($email) |
|
120 | - ; |
|
121 | - $skippGeo = empty($geoDescription) && |
|
122 | - empty($addressLocality) && |
|
123 | - empty($streetAddress) && |
|
124 | - empty($lat) && |
|
125 | - empty($long) ; |
|
126 | - $skippPlace = $skippGeo && $skippAddress; |
|
112 | + $skippAddress = empty($alternateName) && |
|
113 | + empty($addressLocality) && |
|
114 | + empty($streetAddress) && |
|
115 | + empty($postalCode) && |
|
116 | + empty($page) && |
|
117 | + empty($telephone) && |
|
118 | + empty($faxNumber) && |
|
119 | + empty($email) |
|
120 | + ; |
|
121 | + $skippGeo = empty($geoDescription) && |
|
122 | + empty($addressLocality) && |
|
123 | + empty($streetAddress) && |
|
124 | + empty($lat) && |
|
125 | + empty($long) ; |
|
126 | + $skippPlace = $skippGeo && $skippAddress; |
|
127 | 127 | |
128 | - $skippOrganization = $skippPlace && empty($id)&& empty($vatID) && empty($taxID) && empty($legalName) ; |
|
128 | + $skippOrganization = $skippPlace && empty($id)&& empty($vatID) && empty($taxID) && empty($legalName) ; |
|
129 | 129 | |
130 | - // serialize schema:Organization |
|
131 | - if( !$skippOrganization){ |
|
132 | - $rdf.= sprintf( '<%s> a schema:Organization;', $organizationUri); $tc++; |
|
133 | - if(!empty($id)) { $rdf.= sprintf( 'dct:identifier "%s";', $id); $tc++; } |
|
134 | - if(!empty($vatID)) { $rdf.= sprintf( 'schema:vatID "%s"@%s;', $vatID, $lang); $tc++; } |
|
135 | - if(!empty($taxtID)) { $rdf.= sprintf( 'schema:taxtID "%s"@%s;', $taxID, $lang); $tc++; } |
|
136 | - if(!empty($legalName)) { $rdf.= sprintf( 'schema:legalName """%s"""@%s;', $legalName, $lang); $tc++; } |
|
137 | - if( !$skippPlace) { $rdf.= sprintf( 'schema:location <%s>;', $placeUri); $tc++; } |
|
138 | - $rdf.= " . "; |
|
139 | - } |
|
130 | + // serialize schema:Organization |
|
131 | + if( !$skippOrganization){ |
|
132 | + $rdf.= sprintf( '<%s> a schema:Organization;', $organizationUri); $tc++; |
|
133 | + if(!empty($id)) { $rdf.= sprintf( 'dct:identifier "%s";', $id); $tc++; } |
|
134 | + if(!empty($vatID)) { $rdf.= sprintf( 'schema:vatID "%s"@%s;', $vatID, $lang); $tc++; } |
|
135 | + if(!empty($taxtID)) { $rdf.= sprintf( 'schema:taxtID "%s"@%s;', $taxID, $lang); $tc++; } |
|
136 | + if(!empty($legalName)) { $rdf.= sprintf( 'schema:legalName """%s"""@%s;', $legalName, $lang); $tc++; } |
|
137 | + if( !$skippPlace) { $rdf.= sprintf( 'schema:location <%s>;', $placeUri); $tc++; } |
|
138 | + $rdf.= " . "; |
|
139 | + } |
|
140 | 140 | |
141 | - // serialize schema:PostalAddress |
|
142 | - if( !$skippAddress){ |
|
143 | - $rdf.= sprintf( '<%s> a schema:PostalAddress;', $addressUri); $tc++; |
|
144 | - if(!empty($alternateName)) { $rdf.= sprintf( 'schema:alternateName """%s"""@%;', $addressCountry,$lang); $tc++; } |
|
145 | - if(!empty($streetAddress)) { $rdf.= sprintf( 'schema:streetAddress """%s"""@%s;', $streetAddress, $lang); $tc++; } |
|
146 | - if(!empty($postalCode)) { $rdf.= sprintf( 'schema:postalCode "%s"@%s;', $postalCode, $lang); $tc++; } |
|
147 | - if(!empty($addressLocality)) { $rdf.= sprintf( 'schema:addressLocality """%s"""@%s;', $addressLocality, $lang); $tc++; } |
|
148 | - if(!empty($addressRegion)) { $rdf.= sprintf( 'schema:addressRegion """%s"""@%s;', $addressRegion, $lang); $tc++; } |
|
149 | - if(!empty($addressCountry)) { $rdf.= sprintf( 'schema:addressCountry "%s";', $addressCountry); $tc++; } |
|
150 | - if(!empty($telephone)) { $rdf.= sprintf( 'schema:telephone """%s"""@%s;', $telephone, $lang); $tc++; } |
|
151 | - if(!empty($faxNumber)) { $rdf.= sprintf( 'schema:faxNumber """%s"""@%s;', $faxNumber, $lang); $tc++; } |
|
152 | - if(!empty($page)) { $rdf.= sprintf( 'schema:page <%s>;', $page); $tc++; } |
|
153 | - if(!empty($email)) { $rdf.= sprintf( 'schema:email "%s";', $email); $tc++; } |
|
154 | - $rdf.= " . "; |
|
155 | - } |
|
141 | + // serialize schema:PostalAddress |
|
142 | + if( !$skippAddress){ |
|
143 | + $rdf.= sprintf( '<%s> a schema:PostalAddress;', $addressUri); $tc++; |
|
144 | + if(!empty($alternateName)) { $rdf.= sprintf( 'schema:alternateName """%s"""@%;', $addressCountry,$lang); $tc++; } |
|
145 | + if(!empty($streetAddress)) { $rdf.= sprintf( 'schema:streetAddress """%s"""@%s;', $streetAddress, $lang); $tc++; } |
|
146 | + if(!empty($postalCode)) { $rdf.= sprintf( 'schema:postalCode "%s"@%s;', $postalCode, $lang); $tc++; } |
|
147 | + if(!empty($addressLocality)) { $rdf.= sprintf( 'schema:addressLocality """%s"""@%s;', $addressLocality, $lang); $tc++; } |
|
148 | + if(!empty($addressRegion)) { $rdf.= sprintf( 'schema:addressRegion """%s"""@%s;', $addressRegion, $lang); $tc++; } |
|
149 | + if(!empty($addressCountry)) { $rdf.= sprintf( 'schema:addressCountry "%s";', $addressCountry); $tc++; } |
|
150 | + if(!empty($telephone)) { $rdf.= sprintf( 'schema:telephone """%s"""@%s;', $telephone, $lang); $tc++; } |
|
151 | + if(!empty($faxNumber)) { $rdf.= sprintf( 'schema:faxNumber """%s"""@%s;', $faxNumber, $lang); $tc++; } |
|
152 | + if(!empty($page)) { $rdf.= sprintf( 'schema:page <%s>;', $page); $tc++; } |
|
153 | + if(!empty($email)) { $rdf.= sprintf( 'schema:email "%s";', $email); $tc++; } |
|
154 | + $rdf.= " . "; |
|
155 | + } |
|
156 | 156 | |
157 | - // serialize schema:GeoCoordinates |
|
158 | - if( !$skippGeo){ |
|
159 | - $geoLabel = \BOTK\Filters::buildNormalizedAddress($this->data); |
|
160 | - $rdf.= sprintf( '<%s> a schema:GeoCoordinates;', $geoUri); $tc++; |
|
161 | - if(!empty($geoLabel)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoLabel, $lang); $tc++; } |
|
162 | - if(!empty($geoDescription)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoDescription, $lang); $tc++; } |
|
163 | - if(!empty($lat)) { $rdf.= sprintf( 'wgs:lat %s ;', $lat); $tc++; } |
|
164 | - if(!empty($long)) { $rdf.= sprintf( 'wgs:long %s ;', $long); $tc++; } |
|
165 | - $rdf.= " . "; |
|
166 | - } |
|
157 | + // serialize schema:GeoCoordinates |
|
158 | + if( !$skippGeo){ |
|
159 | + $geoLabel = \BOTK\Filters::buildNormalizedAddress($this->data); |
|
160 | + $rdf.= sprintf( '<%s> a schema:GeoCoordinates;', $geoUri); $tc++; |
|
161 | + if(!empty($geoLabel)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoLabel, $lang); $tc++; } |
|
162 | + if(!empty($geoDescription)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoDescription, $lang); $tc++; } |
|
163 | + if(!empty($lat)) { $rdf.= sprintf( 'wgs:lat %s ;', $lat); $tc++; } |
|
164 | + if(!empty($long)) { $rdf.= sprintf( 'wgs:long %s ;', $long); $tc++; } |
|
165 | + $rdf.= " . "; |
|
166 | + } |
|
167 | 167 | |
168 | - // serialize schema:Place |
|
169 | - if( !$skippPlace){ |
|
170 | - $rdf.= sprintf( '<%s> a schema:LocalBusiness;', $placeUri); $tc++; |
|
171 | - if(!$skippAddress) { $rdf.= sprintf( 'schema:address <%s>;', $addressUri); $tc++; } |
|
172 | - if(!$skippGeo) { $rdf.= sprintf( 'schema:geo <%s>;', $geoUri); $tc++; } |
|
173 | - $rdf.= " . "; |
|
174 | - } |
|
168 | + // serialize schema:Place |
|
169 | + if( !$skippPlace){ |
|
170 | + $rdf.= sprintf( '<%s> a schema:LocalBusiness;', $placeUri); $tc++; |
|
171 | + if(!$skippAddress) { $rdf.= sprintf( 'schema:address <%s>;', $addressUri); $tc++; } |
|
172 | + if(!$skippGeo) { $rdf.= sprintf( 'schema:geo <%s>;', $geoUri); $tc++; } |
|
173 | + $rdf.= " . "; |
|
174 | + } |
|
175 | 175 | |
176 | - $this->rdf = $rdf; |
|
177 | - $this->tripleCount = $tc; |
|
178 | - } |
|
176 | + $this->rdf = $rdf; |
|
177 | + $this->tripleCount = $tc; |
|
178 | + } |
|
179 | 179 | |
180 | - return $this->rdf; |
|
181 | - } |
|
180 | + return $this->rdf; |
|
181 | + } |
|
182 | 182 | |
183 | 183 | } |
184 | 184 | \ No newline at end of file |
@@ -12,7 +12,7 @@ discard block |
||
12 | 12 | class LocalBusiness extends AbstractModel implements ModelInterface |
13 | 13 | { |
14 | 14 | |
15 | - static protected $DEFAULT_OPTIONS = array ( |
|
15 | + static protected $DEFAULT_OPTIONS = array( |
|
16 | 16 | 'base' => array( |
17 | 17 | 'default' => 'http://linkeddata.center/botk/resource/', |
18 | 18 | 'filter' => FILTER_SANITIZE_URL, |
@@ -95,21 +95,21 @@ discard block |
||
95 | 95 | |
96 | 96 | public function asTurtle() |
97 | 97 | { |
98 | - if(is_null($this->rdf)) { |
|
99 | - $tc =0; |
|
100 | - $rdf=''; |
|
98 | + if (is_null($this->rdf)) { |
|
99 | + $tc = 0; |
|
100 | + $rdf = ''; |
|
101 | 101 | extract($this->data); |
102 | 102 | |
103 | 103 | // create uris |
104 | - $organizationUri = empty($uri)?($base. (empty($id)?uniqid():$id)):$uri; |
|
104 | + $organizationUri = empty($uri) ? ($base.(empty($id) ? uniqid() : $id)) : $uri; |
|
105 | 105 | $addressUri = $organizationUri.'_address'; |
106 | 106 | $placeUri = $organizationUri.'_place'; |
107 | - $geoUri = ( !empty($lat) && !empty($long) )?"geo:$lat,$long":($organizationUri.'_geo'); |
|
107 | + $geoUri = (!empty($lat) && !empty($long)) ? "geo:$lat,$long" : ($organizationUri.'_geo'); |
|
108 | 108 | |
109 | 109 | |
110 | 110 | // define the minimum condition to skipp the rdf generation |
111 | 111 | |
112 | - $skippAddress = empty($alternateName) && |
|
112 | + $skippAddress = empty($alternateName) && |
|
113 | 113 | empty($addressLocality) && |
114 | 114 | empty($streetAddress) && |
115 | 115 | empty($postalCode) && |
@@ -122,59 +122,59 @@ discard block |
||
122 | 122 | empty($addressLocality) && |
123 | 123 | empty($streetAddress) && |
124 | 124 | empty($lat) && |
125 | - empty($long) ; |
|
125 | + empty($long); |
|
126 | 126 | $skippPlace = $skippGeo && $skippAddress; |
127 | 127 | |
128 | - $skippOrganization = $skippPlace && empty($id)&& empty($vatID) && empty($taxID) && empty($legalName) ; |
|
128 | + $skippOrganization = $skippPlace && empty($id) && empty($vatID) && empty($taxID) && empty($legalName); |
|
129 | 129 | |
130 | 130 | // serialize schema:Organization |
131 | - if( !$skippOrganization){ |
|
132 | - $rdf.= sprintf( '<%s> a schema:Organization;', $organizationUri); $tc++; |
|
133 | - if(!empty($id)) { $rdf.= sprintf( 'dct:identifier "%s";', $id); $tc++; } |
|
134 | - if(!empty($vatID)) { $rdf.= sprintf( 'schema:vatID "%s"@%s;', $vatID, $lang); $tc++; } |
|
135 | - if(!empty($taxtID)) { $rdf.= sprintf( 'schema:taxtID "%s"@%s;', $taxID, $lang); $tc++; } |
|
136 | - if(!empty($legalName)) { $rdf.= sprintf( 'schema:legalName """%s"""@%s;', $legalName, $lang); $tc++; } |
|
137 | - if( !$skippPlace) { $rdf.= sprintf( 'schema:location <%s>;', $placeUri); $tc++; } |
|
138 | - $rdf.= " . "; |
|
131 | + if (!$skippOrganization) { |
|
132 | + $rdf .= sprintf('<%s> a schema:Organization;', $organizationUri); $tc++; |
|
133 | + if (!empty($id)) { $rdf .= sprintf('dct:identifier "%s";', $id); $tc++; } |
|
134 | + if (!empty($vatID)) { $rdf .= sprintf('schema:vatID "%s"@%s;', $vatID, $lang); $tc++; } |
|
135 | + if (!empty($taxtID)) { $rdf .= sprintf('schema:taxtID "%s"@%s;', $taxID, $lang); $tc++; } |
|
136 | + if (!empty($legalName)) { $rdf .= sprintf('schema:legalName """%s"""@%s;', $legalName, $lang); $tc++; } |
|
137 | + if (!$skippPlace) { $rdf .= sprintf('schema:location <%s>;', $placeUri); $tc++; } |
|
138 | + $rdf .= " . "; |
|
139 | 139 | } |
140 | 140 | |
141 | 141 | // serialize schema:PostalAddress |
142 | - if( !$skippAddress){ |
|
143 | - $rdf.= sprintf( '<%s> a schema:PostalAddress;', $addressUri); $tc++; |
|
144 | - if(!empty($alternateName)) { $rdf.= sprintf( 'schema:alternateName """%s"""@%;', $addressCountry,$lang); $tc++; } |
|
145 | - if(!empty($streetAddress)) { $rdf.= sprintf( 'schema:streetAddress """%s"""@%s;', $streetAddress, $lang); $tc++; } |
|
146 | - if(!empty($postalCode)) { $rdf.= sprintf( 'schema:postalCode "%s"@%s;', $postalCode, $lang); $tc++; } |
|
147 | - if(!empty($addressLocality)) { $rdf.= sprintf( 'schema:addressLocality """%s"""@%s;', $addressLocality, $lang); $tc++; } |
|
148 | - if(!empty($addressRegion)) { $rdf.= sprintf( 'schema:addressRegion """%s"""@%s;', $addressRegion, $lang); $tc++; } |
|
149 | - if(!empty($addressCountry)) { $rdf.= sprintf( 'schema:addressCountry "%s";', $addressCountry); $tc++; } |
|
150 | - if(!empty($telephone)) { $rdf.= sprintf( 'schema:telephone """%s"""@%s;', $telephone, $lang); $tc++; } |
|
151 | - if(!empty($faxNumber)) { $rdf.= sprintf( 'schema:faxNumber """%s"""@%s;', $faxNumber, $lang); $tc++; } |
|
152 | - if(!empty($page)) { $rdf.= sprintf( 'schema:page <%s>;', $page); $tc++; } |
|
153 | - if(!empty($email)) { $rdf.= sprintf( 'schema:email "%s";', $email); $tc++; } |
|
154 | - $rdf.= " . "; |
|
142 | + if (!$skippAddress) { |
|
143 | + $rdf .= sprintf('<%s> a schema:PostalAddress;', $addressUri); $tc++; |
|
144 | + if (!empty($alternateName)) { $rdf .= sprintf('schema:alternateName """%s"""@%;', $addressCountry, $lang); $tc++; } |
|
145 | + if (!empty($streetAddress)) { $rdf .= sprintf('schema:streetAddress """%s"""@%s;', $streetAddress, $lang); $tc++; } |
|
146 | + if (!empty($postalCode)) { $rdf .= sprintf('schema:postalCode "%s"@%s;', $postalCode, $lang); $tc++; } |
|
147 | + if (!empty($addressLocality)) { $rdf .= sprintf('schema:addressLocality """%s"""@%s;', $addressLocality, $lang); $tc++; } |
|
148 | + if (!empty($addressRegion)) { $rdf .= sprintf('schema:addressRegion """%s"""@%s;', $addressRegion, $lang); $tc++; } |
|
149 | + if (!empty($addressCountry)) { $rdf .= sprintf('schema:addressCountry "%s";', $addressCountry); $tc++; } |
|
150 | + if (!empty($telephone)) { $rdf .= sprintf('schema:telephone """%s"""@%s;', $telephone, $lang); $tc++; } |
|
151 | + if (!empty($faxNumber)) { $rdf .= sprintf('schema:faxNumber """%s"""@%s;', $faxNumber, $lang); $tc++; } |
|
152 | + if (!empty($page)) { $rdf .= sprintf('schema:page <%s>;', $page); $tc++; } |
|
153 | + if (!empty($email)) { $rdf .= sprintf('schema:email "%s";', $email); $tc++; } |
|
154 | + $rdf .= " . "; |
|
155 | 155 | } |
156 | 156 | |
157 | 157 | // serialize schema:GeoCoordinates |
158 | - if( !$skippGeo){ |
|
158 | + if (!$skippGeo) { |
|
159 | 159 | $geoLabel = \BOTK\Filters::buildNormalizedAddress($this->data); |
160 | - $rdf.= sprintf( '<%s> a schema:GeoCoordinates;', $geoUri); $tc++; |
|
161 | - if(!empty($geoLabel)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoLabel, $lang); $tc++; } |
|
162 | - if(!empty($geoDescription)) { $rdf.= sprintf( 'schema:alternateLabel ""%s""@%s;', $geoDescription, $lang); $tc++; } |
|
163 | - if(!empty($lat)) { $rdf.= sprintf( 'wgs:lat %s ;', $lat); $tc++; } |
|
164 | - if(!empty($long)) { $rdf.= sprintf( 'wgs:long %s ;', $long); $tc++; } |
|
165 | - $rdf.= " . "; |
|
160 | + $rdf .= sprintf('<%s> a schema:GeoCoordinates;', $geoUri); $tc++; |
|
161 | + if (!empty($geoLabel)) { $rdf .= sprintf('schema:alternateLabel ""%s""@%s;', $geoLabel, $lang); $tc++; } |
|
162 | + if (!empty($geoDescription)) { $rdf .= sprintf('schema:alternateLabel ""%s""@%s;', $geoDescription, $lang); $tc++; } |
|
163 | + if (!empty($lat)) { $rdf .= sprintf('wgs:lat %s ;', $lat); $tc++; } |
|
164 | + if (!empty($long)) { $rdf .= sprintf('wgs:long %s ;', $long); $tc++; } |
|
165 | + $rdf .= " . "; |
|
166 | 166 | } |
167 | 167 | |
168 | 168 | // serialize schema:Place |
169 | - if( !$skippPlace){ |
|
170 | - $rdf.= sprintf( '<%s> a schema:LocalBusiness;', $placeUri); $tc++; |
|
171 | - if(!$skippAddress) { $rdf.= sprintf( 'schema:address <%s>;', $addressUri); $tc++; } |
|
172 | - if(!$skippGeo) { $rdf.= sprintf( 'schema:geo <%s>;', $geoUri); $tc++; } |
|
173 | - $rdf.= " . "; |
|
169 | + if (!$skippPlace) { |
|
170 | + $rdf .= sprintf('<%s> a schema:LocalBusiness;', $placeUri); $tc++; |
|
171 | + if (!$skippAddress) { $rdf .= sprintf('schema:address <%s>;', $addressUri); $tc++; } |
|
172 | + if (!$skippGeo) { $rdf .= sprintf('schema:geo <%s>;', $geoUri); $tc++; } |
|
173 | + $rdf .= " . "; |
|
174 | 174 | } |
175 | 175 | |
176 | 176 | $this->rdf = $rdf; |
177 | - $this->tripleCount = $tc; |
|
177 | + $this->tripleCount = $tc; |
|
178 | 178 | } |
179 | 179 | |
180 | 180 | return $this->rdf; |
@@ -12,82 +12,82 @@ |
||
12 | 12 | abstract class AbstractModel |
13 | 13 | { |
14 | 14 | |
15 | - static protected $DEFAULT_OPTIONS = array ( |
|
16 | - ); |
|
15 | + static protected $DEFAULT_OPTIONS = array ( |
|
16 | + ); |
|
17 | 17 | |
18 | 18 | |
19 | - protected $data; |
|
20 | - protected $options; |
|
21 | - protected $rdf =null; //lazy created |
|
22 | - protected $tripleCount=0; //lazy created |
|
19 | + protected $data; |
|
20 | + protected $options; |
|
21 | + protected $rdf =null; //lazy created |
|
22 | + protected $tripleCount=0; //lazy created |
|
23 | 23 | |
24 | 24 | |
25 | 25 | public function __construct(array $data = array(), array $options = array()) |
26 | 26 | { |
27 | - // ensure proper defaults exists |
|
28 | - $this->options = array_merge(static::$DEFAULT_OPTIONS, $options); |
|
27 | + // ensure proper defaults exists |
|
28 | + $this->options = array_merge(static::$DEFAULT_OPTIONS, $options); |
|
29 | 29 | |
30 | - // set default values |
|
31 | - foreach( $this->options as $property=>$option){ |
|
32 | - if(empty($data[$property]) && isset($this->options[$property]['default'])){ |
|
33 | - $data[$property] = $this->options[$property]['default']; |
|
34 | - } |
|
35 | - } |
|
30 | + // set default values |
|
31 | + foreach( $this->options as $property=>$option){ |
|
32 | + if(empty($data[$property]) && isset($this->options[$property]['default'])){ |
|
33 | + $data[$property] = $this->options[$property]['default']; |
|
34 | + } |
|
35 | + } |
|
36 | 36 | |
37 | - // ensure data are sanitized and validated |
|
38 | - $sanitizedData = array(); |
|
39 | - foreach( $data as $property=>$value) { |
|
37 | + // ensure data are sanitized and validated |
|
38 | + $sanitizedData = array(); |
|
39 | + foreach( $data as $property=>$value) { |
|
40 | 40 | |
41 | - // property must exist |
|
42 | - if(!isset($this->options[$property])){ |
|
43 | - throw new DataModelException("Unknown property $property"); |
|
44 | - } |
|
41 | + // property must exist |
|
42 | + if(!isset($this->options[$property])){ |
|
43 | + throw new DataModelException("Unknown property $property"); |
|
44 | + } |
|
45 | 45 | |
46 | - // apply filters to not empty variables |
|
47 | - if( $value ){ |
|
48 | - if(isset($this->options[$property]['filter'])){ |
|
49 | - $sanitizedValue = filter_var($value, $this->options[$property]['filter'], $this->options[$property]); |
|
50 | - if(!$sanitizedValue){ |
|
51 | - throw new DataModelException("Invalid property value for $property ($value)"); |
|
52 | - } |
|
53 | - $sanitizedData[$property]=$sanitizedValue; |
|
54 | - } else { |
|
55 | - $sanitizedData[$property]=$value; |
|
56 | - } |
|
57 | - } |
|
58 | - } |
|
59 | - $this->data = $sanitizedData; |
|
46 | + // apply filters to not empty variables |
|
47 | + if( $value ){ |
|
48 | + if(isset($this->options[$property]['filter'])){ |
|
49 | + $sanitizedValue = filter_var($value, $this->options[$property]['filter'], $this->options[$property]); |
|
50 | + if(!$sanitizedValue){ |
|
51 | + throw new DataModelException("Invalid property value for $property ($value)"); |
|
52 | + } |
|
53 | + $sanitizedData[$property]=$sanitizedValue; |
|
54 | + } else { |
|
55 | + $sanitizedData[$property]=$value; |
|
56 | + } |
|
57 | + } |
|
58 | + } |
|
59 | + $this->data = $sanitizedData; |
|
60 | 60 | } |
61 | 61 | |
62 | 62 | |
63 | - public function asArray() |
|
64 | - { |
|
65 | - return $this->data; |
|
66 | - } |
|
63 | + public function asArray() |
|
64 | + { |
|
65 | + return $this->data; |
|
66 | + } |
|
67 | 67 | |
68 | 68 | |
69 | - public function getOptions() |
|
70 | - { |
|
71 | - return $this->options; |
|
72 | - } |
|
69 | + public function getOptions() |
|
70 | + { |
|
71 | + return $this->options; |
|
72 | + } |
|
73 | 73 | |
74 | 74 | |
75 | - abstract public function asTurtle(); |
|
75 | + abstract public function asTurtle(); |
|
76 | 76 | |
77 | 77 | |
78 | - public function getTripleCount() |
|
79 | - { |
|
80 | - // triple count is computed during rdf creation |
|
81 | - if (is_null($this->rdf)){ |
|
82 | - $this->asTurtle(); |
|
83 | - } |
|
78 | + public function getTripleCount() |
|
79 | + { |
|
80 | + // triple count is computed during rdf creation |
|
81 | + if (is_null($this->rdf)){ |
|
82 | + $this->asTurtle(); |
|
83 | + } |
|
84 | 84 | |
85 | - return $this->tripleCount; |
|
86 | - } |
|
85 | + return $this->tripleCount; |
|
86 | + } |
|
87 | 87 | |
88 | 88 | |
89 | - public function __toString() |
|
90 | - { |
|
91 | - return $this->asTurtle(); |
|
92 | - } |
|
89 | + public function __toString() |
|
90 | + { |
|
91 | + return $this->asTurtle(); |
|
92 | + } |
|
93 | 93 | } |
94 | 94 | \ No newline at end of file |
@@ -12,14 +12,14 @@ discard block |
||
12 | 12 | abstract class AbstractModel |
13 | 13 | { |
14 | 14 | |
15 | - static protected $DEFAULT_OPTIONS = array ( |
|
15 | + static protected $DEFAULT_OPTIONS = array( |
|
16 | 16 | ); |
17 | 17 | |
18 | 18 | |
19 | 19 | protected $data; |
20 | 20 | protected $options; |
21 | - protected $rdf =null; //lazy created |
|
22 | - protected $tripleCount=0; //lazy created |
|
21 | + protected $rdf = null; //lazy created |
|
22 | + protected $tripleCount = 0; //lazy created |
|
23 | 23 | |
24 | 24 | |
25 | 25 | public function __construct(array $data = array(), array $options = array()) |
@@ -28,31 +28,31 @@ discard block |
||
28 | 28 | $this->options = array_merge(static::$DEFAULT_OPTIONS, $options); |
29 | 29 | |
30 | 30 | // set default values |
31 | - foreach( $this->options as $property=>$option){ |
|
32 | - if(empty($data[$property]) && isset($this->options[$property]['default'])){ |
|
31 | + foreach ($this->options as $property=>$option) { |
|
32 | + if (empty($data[$property]) && isset($this->options[$property]['default'])) { |
|
33 | 33 | $data[$property] = $this->options[$property]['default']; |
34 | 34 | } |
35 | 35 | } |
36 | 36 | |
37 | 37 | // ensure data are sanitized and validated |
38 | 38 | $sanitizedData = array(); |
39 | - foreach( $data as $property=>$value) { |
|
39 | + foreach ($data as $property=>$value) { |
|
40 | 40 | |
41 | 41 | // property must exist |
42 | - if(!isset($this->options[$property])){ |
|
42 | + if (!isset($this->options[$property])) { |
|
43 | 43 | throw new DataModelException("Unknown property $property"); |
44 | 44 | } |
45 | 45 | |
46 | 46 | // apply filters to not empty variables |
47 | - if( $value ){ |
|
48 | - if(isset($this->options[$property]['filter'])){ |
|
47 | + if ($value) { |
|
48 | + if (isset($this->options[$property]['filter'])) { |
|
49 | 49 | $sanitizedValue = filter_var($value, $this->options[$property]['filter'], $this->options[$property]); |
50 | - if(!$sanitizedValue){ |
|
50 | + if (!$sanitizedValue) { |
|
51 | 51 | throw new DataModelException("Invalid property value for $property ($value)"); |
52 | 52 | } |
53 | - $sanitizedData[$property]=$sanitizedValue; |
|
53 | + $sanitizedData[$property] = $sanitizedValue; |
|
54 | 54 | } else { |
55 | - $sanitizedData[$property]=$value; |
|
55 | + $sanitizedData[$property] = $value; |
|
56 | 56 | } |
57 | 57 | } |
58 | 58 | } |
@@ -78,7 +78,7 @@ discard block |
||
78 | 78 | public function getTripleCount() |
79 | 79 | { |
80 | 80 | // triple count is computed during rdf creation |
81 | - if (is_null($this->rdf)){ |
|
81 | + if (is_null($this->rdf)) { |
|
82 | 82 | $this->asTurtle(); |
83 | 83 | } |
84 | 84 |
@@ -4,10 +4,10 @@ |
||
4 | 4 | Interface ModelInterface |
5 | 5 | { |
6 | 6 | |
7 | - public function asArray(); |
|
8 | - public function getOptions(); |
|
9 | - public function asTurtle(); |
|
10 | - public function getTripleCount(); |
|
11 | - public function __toString(); |
|
7 | + public function asArray(); |
|
8 | + public function getOptions(); |
|
9 | + public function asTurtle(); |
|
10 | + public function getTripleCount(); |
|
11 | + public function __toString(); |
|
12 | 12 | |
13 | 13 | } |
14 | 14 | \ No newline at end of file |
@@ -3,24 +3,24 @@ |
||
3 | 3 | |
4 | 4 | class FactsFactory implements FactsFactoryInterface { |
5 | 5 | |
6 | - private $profile; |
|
6 | + private $profile; |
|
7 | 7 | |
8 | - public function __construct( array $profile) |
|
9 | - { |
|
10 | - assert(!empty($profile['model']) && class_exists('\BOTK\Model\\'.$profile['model'])); |
|
11 | - assert(isset($profile['datamapper']) && is_callable($profile['datamapper'])); |
|
12 | - assert(isset($profile['options']) && is_array($profile['options'])); |
|
13 | - $this->profile = $profile; |
|
14 | - } |
|
8 | + public function __construct( array $profile) |
|
9 | + { |
|
10 | + assert(!empty($profile['model']) && class_exists('\BOTK\Model\\'.$profile['model'])); |
|
11 | + assert(isset($profile['datamapper']) && is_callable($profile['datamapper'])); |
|
12 | + assert(isset($profile['options']) && is_array($profile['options'])); |
|
13 | + $this->profile = $profile; |
|
14 | + } |
|
15 | 15 | |
16 | - public function factualize( array $rawData){ |
|
17 | - $data = array(); |
|
18 | - $numOfRawData = count($rawData); |
|
19 | - $datamapper = $this->profile['datamapper']; |
|
20 | - $class = '\BOTK\Model\\'.$this->profile['model']; |
|
21 | - $data = $datamapper($rawData); |
|
16 | + public function factualize( array $rawData){ |
|
17 | + $data = array(); |
|
18 | + $numOfRawData = count($rawData); |
|
19 | + $datamapper = $this->profile['datamapper']; |
|
20 | + $class = '\BOTK\Model\\'.$this->profile['model']; |
|
21 | + $data = $datamapper($rawData); |
|
22 | 22 | |
23 | - return new $class($data,$this->profile['options']); |
|
24 | - } |
|
23 | + return new $class($data,$this->profile['options']); |
|
24 | + } |
|
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -5,7 +5,7 @@ discard block |
||
5 | 5 | |
6 | 6 | private $profile; |
7 | 7 | |
8 | - public function __construct( array $profile) |
|
8 | + public function __construct(array $profile) |
|
9 | 9 | { |
10 | 10 | assert(!empty($profile['model']) && class_exists('\BOTK\Model\\'.$profile['model'])); |
11 | 11 | assert(isset($profile['datamapper']) && is_callable($profile['datamapper'])); |
@@ -13,14 +13,14 @@ discard block |
||
13 | 13 | $this->profile = $profile; |
14 | 14 | } |
15 | 15 | |
16 | - public function factualize( array $rawData){ |
|
16 | + public function factualize(array $rawData) { |
|
17 | 17 | $data = array(); |
18 | 18 | $numOfRawData = count($rawData); |
19 | 19 | $datamapper = $this->profile['datamapper']; |
20 | 20 | $class = '\BOTK\Model\\'.$this->profile['model']; |
21 | 21 | $data = $datamapper($rawData); |
22 | 22 | |
23 | - return new $class($data,$this->profile['options']); |
|
23 | + return new $class($data, $this->profile['options']); |
|
24 | 24 | } |
25 | 25 | |
26 | 26 | } |
27 | 27 | \ No newline at end of file |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | Interface FactsFactoryInterface { |
5 | 5 | |
6 | - public function factualize( array $rawData); |
|
6 | + public function factualize( array $rawData); |
|
7 | 7 | |
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -3,6 +3,6 @@ |
||
3 | 3 | |
4 | 4 | Interface FactsFactoryInterface { |
5 | 5 | |
6 | - public function factualize( array $rawData); |
|
6 | + public function factualize(array $rawData); |
|
7 | 7 | |
8 | 8 | } |
9 | 9 | \ No newline at end of file |
@@ -5,119 +5,119 @@ |
||
5 | 5 | /** |
6 | 6 | * @dataProvider telephones |
7 | 7 | */ |
8 | - public function testItTelephoneFilter($data, $expectedData) |
|
9 | - { |
|
10 | - $this->assertEquals($expectedData, BOTK\Filters::normalizeItTelephone($data)); |
|
11 | - } |
|
8 | + public function testItTelephoneFilter($data, $expectedData) |
|
9 | + { |
|
10 | + $this->assertEquals($expectedData, BOTK\Filters::normalizeItTelephone($data)); |
|
11 | + } |
|
12 | 12 | |
13 | - public function telephones() |
|
13 | + public function telephones() |
|
14 | 14 | { |
15 | - return array( |
|
16 | - array( '+39 0341 2333991', '03412333991'), |
|
17 | - array( ' +39 0341 2333991 ', '03412333991'), |
|
18 | - array( '03412333991', '03412333991'), |
|
19 | - array( '003903412333991', '03412333991'), |
|
20 | - array( '00390341 23 33991', '03412333991'), |
|
21 | - array( '+39 0341 2333991', '03412333991'), |
|
22 | - array( '+39 03412333991', '03412333991'), |
|
23 | - array( '+39 0341 23 33 991', '03412333991'), |
|
24 | - array( '+39 (0341) 2333991', '03412333991'), |
|
25 | - array( '+39 (0341) 2333991 ext. 1234', '03412333991 [1234]'), |
|
26 | - array( '+39 (0341) 2333991 {1234]', '03412333991 [1234]'), |
|
27 | - array( ' apdas 0341 2333991sfsd12sdfsf 34', '03412333991 [1234]'), |
|
28 | - array( ' apdassdfs',''), |
|
29 | - ); |
|
30 | - } |
|
15 | + return array( |
|
16 | + array( '+39 0341 2333991', '03412333991'), |
|
17 | + array( ' +39 0341 2333991 ', '03412333991'), |
|
18 | + array( '03412333991', '03412333991'), |
|
19 | + array( '003903412333991', '03412333991'), |
|
20 | + array( '00390341 23 33991', '03412333991'), |
|
21 | + array( '+39 0341 2333991', '03412333991'), |
|
22 | + array( '+39 03412333991', '03412333991'), |
|
23 | + array( '+39 0341 23 33 991', '03412333991'), |
|
24 | + array( '+39 (0341) 2333991', '03412333991'), |
|
25 | + array( '+39 (0341) 2333991 ext. 1234', '03412333991 [1234]'), |
|
26 | + array( '+39 (0341) 2333991 {1234]', '03412333991 [1234]'), |
|
27 | + array( ' apdas 0341 2333991sfsd12sdfsf 34', '03412333991 [1234]'), |
|
28 | + array( ' apdassdfs',''), |
|
29 | + ); |
|
30 | + } |
|
31 | 31 | |
32 | - public function testEmailFilter() |
|
33 | - { |
|
34 | - $this->assertEquals('[email protected]', BOTK\Filters::normalizeEmail('[email protected]')); |
|
35 | - $this->assertTrue(empty(BOTK\Filters::normalizeEmail('invalid email'))); |
|
36 | - } |
|
32 | + public function testEmailFilter() |
|
33 | + { |
|
34 | + $this->assertEquals('[email protected]', BOTK\Filters::normalizeEmail('[email protected]')); |
|
35 | + $this->assertTrue(empty(BOTK\Filters::normalizeEmail('invalid email'))); |
|
36 | + } |
|
37 | 37 | |
38 | 38 | /** |
39 | 39 | * @dataProvider tokens |
40 | 40 | */ |
41 | - public function testTokenFilter($data, $expectedData) |
|
42 | - { |
|
43 | - $this->assertEquals($expectedData, BOTK\Filters::normalizeToken($data)); |
|
44 | - } |
|
41 | + public function testTokenFilter($data, $expectedData) |
|
42 | + { |
|
43 | + $this->assertEquals($expectedData, BOTK\Filters::normalizeToken($data)); |
|
44 | + } |
|
45 | 45 | |
46 | - public function tokens() |
|
46 | + public function tokens() |
|
47 | 47 | { |
48 | - return array( |
|
49 | - array( 'abc d e #1', 'ABCDE1'), |
|
50 | - array( 'abcde1', 'ABCDE1'), |
|
51 | - array( 'ABCDE1', 'ABCDE1'), |
|
52 | - array( ' ABC_DE-1 ', 'ABC_DE1'), |
|
53 | - array( ' ABC_DE:1 ', 'ABC_DE1'), |
|
54 | - ); |
|
55 | - } |
|
48 | + return array( |
|
49 | + array( 'abc d e #1', 'ABCDE1'), |
|
50 | + array( 'abcde1', 'ABCDE1'), |
|
51 | + array( 'ABCDE1', 'ABCDE1'), |
|
52 | + array( ' ABC_DE-1 ', 'ABC_DE1'), |
|
53 | + array( ' ABC_DE:1 ', 'ABC_DE1'), |
|
54 | + ); |
|
55 | + } |
|
56 | 56 | |
57 | 57 | /** |
58 | 58 | * @dataProvider adresses |
59 | 59 | */ |
60 | - public function testAddressFilter($data, $expectedData) |
|
61 | - { |
|
62 | - $this->assertEquals($expectedData, BOTK\Filters::normalizeAddress($data)); |
|
63 | - } |
|
60 | + public function testAddressFilter($data, $expectedData) |
|
61 | + { |
|
62 | + $this->assertEquals($expectedData, BOTK\Filters::normalizeAddress($data)); |
|
63 | + } |
|
64 | 64 | |
65 | - public function adresses() |
|
65 | + public function adresses() |
|
66 | 66 | { |
67 | - return array( |
|
68 | - array( 'Lungolario Luigi Cadorna, 1, 23900 Lecco LC, Italy', 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO LC, ITALY'), |
|
69 | - array( 'Lungolario Luigi Cadorna 1-23900 Lecco LC - Italy', 'LUNGOLARIO LUIGI CADORNA 1 - 23900 LECCO LC - ITALY'), |
|
70 | - array( 'Lungolario Luigi Cadorna 1 Lecco LC - -Italy', 'LUNGOLARIO LUIGI CADORNA 1 LECCO LC - ITALY'), |
|
71 | - array( ',,test;;', 'TEST;'), |
|
72 | - ); |
|
73 | - } |
|
67 | + return array( |
|
68 | + array( 'Lungolario Luigi Cadorna, 1, 23900 Lecco LC, Italy', 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO LC, ITALY'), |
|
69 | + array( 'Lungolario Luigi Cadorna 1-23900 Lecco LC - Italy', 'LUNGOLARIO LUIGI CADORNA 1 - 23900 LECCO LC - ITALY'), |
|
70 | + array( 'Lungolario Luigi Cadorna 1 Lecco LC - -Italy', 'LUNGOLARIO LUIGI CADORNA 1 LECCO LC - ITALY'), |
|
71 | + array( ',,test;;', 'TEST;'), |
|
72 | + ); |
|
73 | + } |
|
74 | 74 | |
75 | 75 | |
76 | 76 | /** |
77 | 77 | * @dataProvider structuredAdresses |
78 | 78 | */ |
79 | - public function testBuildNormalizedAddress($data, $expectedData) |
|
80 | - { |
|
81 | - $this->assertEquals($expectedData, BOTK\Filters::buildNormalizedAddress($data)); |
|
82 | - } |
|
79 | + public function testBuildNormalizedAddress($data, $expectedData) |
|
80 | + { |
|
81 | + $this->assertEquals($expectedData, BOTK\Filters::buildNormalizedAddress($data)); |
|
82 | + } |
|
83 | 83 | |
84 | - public function structuredAdresses() |
|
84 | + public function structuredAdresses() |
|
85 | 85 | { |
86 | - return array( |
|
87 | - array( |
|
88 | - array( |
|
89 | - 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
90 | - 'addressLocality' => 'Lecco', |
|
91 | - 'addressRegion' => 'LC', |
|
92 | - 'addressCountry' => 'IT', |
|
93 | - 'postalCode' => '23900', |
|
94 | - ), |
|
95 | - 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO (LC) - IT' |
|
96 | - ), |
|
97 | - array( |
|
98 | - array( |
|
99 | - 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
100 | - 'addressLocality' => 'Lecco', |
|
101 | - 'addressCountry' => 'IT', |
|
102 | - ), |
|
103 | - 'LUNGOLARIO LUIGI CADORNA, 1, LECCO - IT' |
|
104 | - ), |
|
105 | - array( |
|
106 | - array( |
|
107 | - 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
108 | - 'addressCountry' => 'IT', |
|
109 | - 'postalCode' => '23900', |
|
110 | - ), |
|
111 | - 'LUNGOLARIO LUIGI CADORNA, 1, 23900 - IT' |
|
112 | - ), |
|
113 | - array( |
|
114 | - array( |
|
115 | - 'addressCountry' => 'IT', |
|
116 | - 'postalCode' => '23900', |
|
117 | - ), |
|
118 | - false |
|
119 | - ), |
|
120 | - ); |
|
121 | - } |
|
86 | + return array( |
|
87 | + array( |
|
88 | + array( |
|
89 | + 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
90 | + 'addressLocality' => 'Lecco', |
|
91 | + 'addressRegion' => 'LC', |
|
92 | + 'addressCountry' => 'IT', |
|
93 | + 'postalCode' => '23900', |
|
94 | + ), |
|
95 | + 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO (LC) - IT' |
|
96 | + ), |
|
97 | + array( |
|
98 | + array( |
|
99 | + 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
100 | + 'addressLocality' => 'Lecco', |
|
101 | + 'addressCountry' => 'IT', |
|
102 | + ), |
|
103 | + 'LUNGOLARIO LUIGI CADORNA, 1, LECCO - IT' |
|
104 | + ), |
|
105 | + array( |
|
106 | + array( |
|
107 | + 'streetAddress' => 'Lungolario Luigi Cadorna, 1', |
|
108 | + 'addressCountry' => 'IT', |
|
109 | + 'postalCode' => '23900', |
|
110 | + ), |
|
111 | + 'LUNGOLARIO LUIGI CADORNA, 1, 23900 - IT' |
|
112 | + ), |
|
113 | + array( |
|
114 | + array( |
|
115 | + 'addressCountry' => 'IT', |
|
116 | + 'postalCode' => '23900', |
|
117 | + ), |
|
118 | + false |
|
119 | + ), |
|
120 | + ); |
|
121 | + } |
|
122 | 122 | } |
123 | 123 |
@@ -13,19 +13,19 @@ discard block |
||
13 | 13 | public function telephones() |
14 | 14 | { |
15 | 15 | return array( |
16 | - array( '+39 0341 2333991', '03412333991'), |
|
17 | - array( ' +39 0341 2333991 ', '03412333991'), |
|
18 | - array( '03412333991', '03412333991'), |
|
19 | - array( '003903412333991', '03412333991'), |
|
20 | - array( '00390341 23 33991', '03412333991'), |
|
21 | - array( '+39 0341 2333991', '03412333991'), |
|
22 | - array( '+39 03412333991', '03412333991'), |
|
23 | - array( '+39 0341 23 33 991', '03412333991'), |
|
24 | - array( '+39 (0341) 2333991', '03412333991'), |
|
25 | - array( '+39 (0341) 2333991 ext. 1234', '03412333991 [1234]'), |
|
26 | - array( '+39 (0341) 2333991 {1234]', '03412333991 [1234]'), |
|
27 | - array( ' apdas 0341 2333991sfsd12sdfsf 34', '03412333991 [1234]'), |
|
28 | - array( ' apdassdfs',''), |
|
16 | + array('+39 0341 2333991', '03412333991'), |
|
17 | + array(' +39 0341 2333991 ', '03412333991'), |
|
18 | + array('03412333991', '03412333991'), |
|
19 | + array('003903412333991', '03412333991'), |
|
20 | + array('00390341 23 33991', '03412333991'), |
|
21 | + array('+39 0341 2333991', '03412333991'), |
|
22 | + array('+39 03412333991', '03412333991'), |
|
23 | + array('+39 0341 23 33 991', '03412333991'), |
|
24 | + array('+39 (0341) 2333991', '03412333991'), |
|
25 | + array('+39 (0341) 2333991 ext. 1234', '03412333991 [1234]'), |
|
26 | + array('+39 (0341) 2333991 {1234]', '03412333991 [1234]'), |
|
27 | + array(' apdas 0341 2333991sfsd12sdfsf 34', '03412333991 [1234]'), |
|
28 | + array(' apdassdfs', ''), |
|
29 | 29 | ); |
30 | 30 | } |
31 | 31 | |
@@ -46,11 +46,11 @@ discard block |
||
46 | 46 | public function tokens() |
47 | 47 | { |
48 | 48 | return array( |
49 | - array( 'abc d e #1', 'ABCDE1'), |
|
50 | - array( 'abcde1', 'ABCDE1'), |
|
51 | - array( 'ABCDE1', 'ABCDE1'), |
|
52 | - array( ' ABC_DE-1 ', 'ABC_DE1'), |
|
53 | - array( ' ABC_DE:1 ', 'ABC_DE1'), |
|
49 | + array('abc d e #1', 'ABCDE1'), |
|
50 | + array('abcde1', 'ABCDE1'), |
|
51 | + array('ABCDE1', 'ABCDE1'), |
|
52 | + array(' ABC_DE-1 ', 'ABC_DE1'), |
|
53 | + array(' ABC_DE:1 ', 'ABC_DE1'), |
|
54 | 54 | ); |
55 | 55 | } |
56 | 56 | |
@@ -65,10 +65,10 @@ discard block |
||
65 | 65 | public function adresses() |
66 | 66 | { |
67 | 67 | return array( |
68 | - array( 'Lungolario Luigi Cadorna, 1, 23900 Lecco LC, Italy', 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO LC, ITALY'), |
|
69 | - array( 'Lungolario Luigi Cadorna 1-23900 Lecco LC - Italy', 'LUNGOLARIO LUIGI CADORNA 1 - 23900 LECCO LC - ITALY'), |
|
70 | - array( 'Lungolario Luigi Cadorna 1 Lecco LC - -Italy', 'LUNGOLARIO LUIGI CADORNA 1 LECCO LC - ITALY'), |
|
71 | - array( ',,test;;', 'TEST;'), |
|
68 | + array('Lungolario Luigi Cadorna, 1, 23900 Lecco LC, Italy', 'LUNGOLARIO LUIGI CADORNA, 1, 23900 LECCO LC, ITALY'), |
|
69 | + array('Lungolario Luigi Cadorna 1-23900 Lecco LC - Italy', 'LUNGOLARIO LUIGI CADORNA 1 - 23900 LECCO LC - ITALY'), |
|
70 | + array('Lungolario Luigi Cadorna 1 Lecco LC - -Italy', 'LUNGOLARIO LUIGI CADORNA 1 LECCO LC - ITALY'), |
|
71 | + array(',,test;;', 'TEST;'), |
|
72 | 72 | ); |
73 | 73 | } |
74 | 74 |
@@ -5,241 +5,241 @@ |
||
5 | 5 | /** |
6 | 6 | * @dataProvider goodLocalBusiness |
7 | 7 | */ |
8 | - public function testDataFilteringWithValidDataAndDefaultOptions($data, $expectedData) |
|
9 | - { |
|
10 | - $localBusiness = new BOTK\Model\LocalBusiness($data); |
|
11 | - $this->assertEquals($expectedData, $localBusiness->asArray()); |
|
12 | - } |
|
8 | + public function testDataFilteringWithValidDataAndDefaultOptions($data, $expectedData) |
|
9 | + { |
|
10 | + $localBusiness = new BOTK\Model\LocalBusiness($data); |
|
11 | + $this->assertEquals($expectedData, $localBusiness->asArray()); |
|
12 | + } |
|
13 | 13 | |
14 | - public function goodLocalBusiness() |
|
14 | + public function goodLocalBusiness() |
|
15 | 15 | { |
16 | - return array( |
|
17 | - array( |
|
18 | - array(), |
|
19 | - array( |
|
20 | - 'base' => 'http://linkeddata.center/botk/resource/', |
|
21 | - 'lang' => 'it', |
|
22 | - 'addressCountry' => 'IT', |
|
23 | - ), |
|
24 | - ), |
|
16 | + return array( |
|
17 | + array( |
|
18 | + array(), |
|
19 | + array( |
|
20 | + 'base' => 'http://linkeddata.center/botk/resource/', |
|
21 | + 'lang' => 'it', |
|
22 | + 'addressCountry' => 'IT', |
|
23 | + ), |
|
24 | + ), |
|
25 | 25 | |
26 | - array( |
|
27 | - array( |
|
28 | - 'base' => 'http://linkeddata.center/botk/resource#', |
|
29 | - 'lang' => 'en', |
|
30 | - 'addressCountry' => 'US', |
|
31 | - ), |
|
32 | - array( |
|
33 | - 'base' => 'http://linkeddata.center/botk/resource#', |
|
34 | - 'lang' => 'en', |
|
35 | - 'addressCountry' => 'US', |
|
36 | - ), |
|
37 | - ), |
|
26 | + array( |
|
27 | + array( |
|
28 | + 'base' => 'http://linkeddata.center/botk/resource#', |
|
29 | + 'lang' => 'en', |
|
30 | + 'addressCountry' => 'US', |
|
31 | + ), |
|
32 | + array( |
|
33 | + 'base' => 'http://linkeddata.center/botk/resource#', |
|
34 | + 'lang' => 'en', |
|
35 | + 'addressCountry' => 'US', |
|
36 | + ), |
|
37 | + ), |
|
38 | 38 | |
39 | - array( |
|
40 | - array( |
|
41 | - 'id' => '1234567890', |
|
42 | - 'taxID' => 'fgn nrc 63S0 6F205 A', |
|
43 | - 'vatID' => '01234567890', |
|
44 | - 'legalName' => 'Test soc srl', |
|
45 | - 'alternateName' => 'Test soc srl', |
|
46 | - 'addressCountry' => 'IT', |
|
47 | - 'addressLocality' => 'LECCO', |
|
48 | - 'addressRegion' => 'LC', |
|
49 | - 'streetAddress' => 'Via F. Valsecchi,124', |
|
50 | - 'postalCode' => '23900', |
|
51 | - 'page' => 'http://linkeddata.center/', |
|
52 | - 'telephone' => '+39 3356382949', |
|
53 | - 'faxNumber' => '0341 255188 ', |
|
54 | - 'email' => '[email protected]', |
|
55 | - 'geoDescription' => 'Via F. Valsecchi,124-23900 Lecco (LC)', |
|
56 | - 'lat' => '1.12345', |
|
57 | - 'long' => '2.123456', |
|
58 | - ), |
|
59 | - array( |
|
60 | - 'base' => 'http://linkeddata.center/botk/resource/', |
|
61 | - 'lang' => 'it', |
|
62 | - 'id' => '1234567890', |
|
63 | - 'taxID' => 'FGNNRC63S06F205A', |
|
64 | - 'vatID' => '01234567890', |
|
65 | - 'legalName' => 'TEST SOC SRL', |
|
66 | - 'alternateName' => 'Test soc srl', |
|
67 | - 'addressCountry' => 'IT', |
|
68 | - 'addressLocality' => 'LECCO', |
|
69 | - 'addressRegion' => 'LC', |
|
70 | - 'streetAddress' => 'VIA F.VALSECCHI, 124', |
|
71 | - 'postalCode' => '23900', |
|
72 | - 'page' => 'http://linkeddata.center/', |
|
73 | - 'telephone' => '3356382949', |
|
74 | - 'faxNumber' => '0341255188', |
|
75 | - 'email' => '[email protected]', |
|
76 | - 'geoDescription' => 'VIA F.VALSECCHI, 124 - 23900 LECCO (LC)', |
|
77 | - 'lat' => '1.12345', |
|
78 | - 'long' => '2.123456', |
|
79 | - ), |
|
80 | - ), |
|
81 | - array( |
|
82 | - array( |
|
83 | - 'id' => '1234567890', |
|
84 | - 'taxID' => '', |
|
85 | - 'vatID' => '', |
|
86 | - 'legalName' => null, |
|
87 | - 'alternateName' => '', |
|
88 | - 'addressCountry' => null, |
|
89 | - ), |
|
90 | - array( |
|
91 | - 'base' => 'http://linkeddata.center/botk/resource/', |
|
92 | - 'lang' => 'it', |
|
93 | - 'id' => '1234567890', |
|
94 | - 'addressCountry' => 'IT', |
|
95 | - ), |
|
96 | - ), |
|
97 | - ); |
|
98 | - } |
|
39 | + array( |
|
40 | + array( |
|
41 | + 'id' => '1234567890', |
|
42 | + 'taxID' => 'fgn nrc 63S0 6F205 A', |
|
43 | + 'vatID' => '01234567890', |
|
44 | + 'legalName' => 'Test soc srl', |
|
45 | + 'alternateName' => 'Test soc srl', |
|
46 | + 'addressCountry' => 'IT', |
|
47 | + 'addressLocality' => 'LECCO', |
|
48 | + 'addressRegion' => 'LC', |
|
49 | + 'streetAddress' => 'Via F. Valsecchi,124', |
|
50 | + 'postalCode' => '23900', |
|
51 | + 'page' => 'http://linkeddata.center/', |
|
52 | + 'telephone' => '+39 3356382949', |
|
53 | + 'faxNumber' => '0341 255188 ', |
|
54 | + 'email' => '[email protected]', |
|
55 | + 'geoDescription' => 'Via F. Valsecchi,124-23900 Lecco (LC)', |
|
56 | + 'lat' => '1.12345', |
|
57 | + 'long' => '2.123456', |
|
58 | + ), |
|
59 | + array( |
|
60 | + 'base' => 'http://linkeddata.center/botk/resource/', |
|
61 | + 'lang' => 'it', |
|
62 | + 'id' => '1234567890', |
|
63 | + 'taxID' => 'FGNNRC63S06F205A', |
|
64 | + 'vatID' => '01234567890', |
|
65 | + 'legalName' => 'TEST SOC SRL', |
|
66 | + 'alternateName' => 'Test soc srl', |
|
67 | + 'addressCountry' => 'IT', |
|
68 | + 'addressLocality' => 'LECCO', |
|
69 | + 'addressRegion' => 'LC', |
|
70 | + 'streetAddress' => 'VIA F.VALSECCHI, 124', |
|
71 | + 'postalCode' => '23900', |
|
72 | + 'page' => 'http://linkeddata.center/', |
|
73 | + 'telephone' => '3356382949', |
|
74 | + 'faxNumber' => '0341255188', |
|
75 | + 'email' => '[email protected]', |
|
76 | + 'geoDescription' => 'VIA F.VALSECCHI, 124 - 23900 LECCO (LC)', |
|
77 | + 'lat' => '1.12345', |
|
78 | + 'long' => '2.123456', |
|
79 | + ), |
|
80 | + ), |
|
81 | + array( |
|
82 | + array( |
|
83 | + 'id' => '1234567890', |
|
84 | + 'taxID' => '', |
|
85 | + 'vatID' => '', |
|
86 | + 'legalName' => null, |
|
87 | + 'alternateName' => '', |
|
88 | + 'addressCountry' => null, |
|
89 | + ), |
|
90 | + array( |
|
91 | + 'base' => 'http://linkeddata.center/botk/resource/', |
|
92 | + 'lang' => 'it', |
|
93 | + 'id' => '1234567890', |
|
94 | + 'addressCountry' => 'IT', |
|
95 | + ), |
|
96 | + ), |
|
97 | + ); |
|
98 | + } |
|
99 | 99 | |
100 | - public function testGetDefaultOptions() |
|
101 | - { |
|
102 | - $options = array ( |
|
103 | - 'base' => array(), |
|
104 | - 'lang' => array( |
|
105 | - 'default' => 'en', |
|
106 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
107 | - 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
108 | - ), |
|
109 | - ); |
|
100 | + public function testGetDefaultOptions() |
|
101 | + { |
|
102 | + $options = array ( |
|
103 | + 'base' => array(), |
|
104 | + 'lang' => array( |
|
105 | + 'default' => 'en', |
|
106 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
107 | + 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
108 | + ), |
|
109 | + ); |
|
110 | 110 | |
111 | - $expectedOptions =array ( |
|
112 | - 'base' => array(), |
|
113 | - 'uri' => array( |
|
114 | - 'filter' => FILTER_SANITIZE_URL, |
|
115 | - ), |
|
116 | - 'lang' => array( |
|
117 | - 'default' => 'en', |
|
118 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
119 | - 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
120 | - ), |
|
121 | - 'id' => array( |
|
122 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
123 | - 'options' => array('regexp'=>'/^[\w]+$/') |
|
124 | - ), |
|
125 | - 'taxID' => array( |
|
126 | - 'filter' => FILTER_CALLBACK, |
|
127 | - 'options' => '\BOTK\Filters::normalizeToken' |
|
128 | - ), |
|
129 | - 'vatID' => array( // italian rules |
|
130 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
131 | - 'options' => array('regexp'=>'/^[0-9]{11}$/') |
|
132 | - ), |
|
133 | - 'legalName' => array( |
|
134 | - 'filter' => FILTER_CALLBACK, |
|
135 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
136 | - ), |
|
137 | - 'alternateName' => array(), |
|
138 | - 'addressCountry' => array( |
|
139 | - 'default' => 'IT', |
|
140 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
141 | - 'options' => array('regexp'=>'/^[A-Z]{2}$/') |
|
142 | - ), |
|
143 | - 'addressLocality' => array( |
|
144 | - 'filter' => FILTER_CALLBACK, |
|
145 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
146 | - ), |
|
147 | - 'addressRegion' => array( |
|
148 | - 'filter' => FILTER_CALLBACK, |
|
149 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
150 | - ), |
|
151 | - 'streetAddress' => array( |
|
152 | - 'filter' => FILTER_CALLBACK, |
|
153 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
154 | - ), |
|
155 | - 'postalCode' => array( // italian rules |
|
156 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
157 | - 'options' => array('regexp'=>'/^[0-9]{5}$/') |
|
158 | - ), |
|
159 | - 'page' => array( |
|
160 | - 'filter' => FILTER_SANITIZE_URL |
|
161 | - ), |
|
162 | - 'telephone' => array( |
|
163 | - 'filter' => FILTER_CALLBACK, |
|
164 | - 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
165 | - ), |
|
166 | - 'faxNumber' => array( |
|
167 | - 'filter' => FILTER_CALLBACK, |
|
168 | - 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
169 | - ), |
|
170 | - 'email' => array( |
|
171 | - 'filter' => FILTER_CALLBACK, |
|
172 | - 'options' => '\BOTK\Filters::normalizeEmail' |
|
173 | - ), |
|
174 | - 'geoDescription' => array( |
|
175 | - 'filter' => FILTER_CALLBACK, |
|
176 | - 'options' => '\BOTK\Filters::normalizeAddress' |
|
177 | - ), |
|
178 | - 'lat' => array( // http://www.regexlib.com/REDetails.aspx?regexp_id=2728 |
|
179 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
180 | - 'options' => array('regexp'=>'/^-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
181 | - ), |
|
182 | - 'long' => array( // http://stackoverflow.com/questions/3518504/regular-expression-for-matching-latitude-longitude-coordinates |
|
183 | - 'filter' => FILTER_VALIDATE_REGEXP, |
|
184 | - 'options' => array('regexp'=>'/-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
185 | - ), |
|
186 | - ); |
|
111 | + $expectedOptions =array ( |
|
112 | + 'base' => array(), |
|
113 | + 'uri' => array( |
|
114 | + 'filter' => FILTER_SANITIZE_URL, |
|
115 | + ), |
|
116 | + 'lang' => array( |
|
117 | + 'default' => 'en', |
|
118 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
119 | + 'options' => array('regexp'=>'/^[a-z]{2}$/') |
|
120 | + ), |
|
121 | + 'id' => array( |
|
122 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
123 | + 'options' => array('regexp'=>'/^[\w]+$/') |
|
124 | + ), |
|
125 | + 'taxID' => array( |
|
126 | + 'filter' => FILTER_CALLBACK, |
|
127 | + 'options' => '\BOTK\Filters::normalizeToken' |
|
128 | + ), |
|
129 | + 'vatID' => array( // italian rules |
|
130 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
131 | + 'options' => array('regexp'=>'/^[0-9]{11}$/') |
|
132 | + ), |
|
133 | + 'legalName' => array( |
|
134 | + 'filter' => FILTER_CALLBACK, |
|
135 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
136 | + ), |
|
137 | + 'alternateName' => array(), |
|
138 | + 'addressCountry' => array( |
|
139 | + 'default' => 'IT', |
|
140 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
141 | + 'options' => array('regexp'=>'/^[A-Z]{2}$/') |
|
142 | + ), |
|
143 | + 'addressLocality' => array( |
|
144 | + 'filter' => FILTER_CALLBACK, |
|
145 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
146 | + ), |
|
147 | + 'addressRegion' => array( |
|
148 | + 'filter' => FILTER_CALLBACK, |
|
149 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
150 | + ), |
|
151 | + 'streetAddress' => array( |
|
152 | + 'filter' => FILTER_CALLBACK, |
|
153 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
154 | + ), |
|
155 | + 'postalCode' => array( // italian rules |
|
156 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
157 | + 'options' => array('regexp'=>'/^[0-9]{5}$/') |
|
158 | + ), |
|
159 | + 'page' => array( |
|
160 | + 'filter' => FILTER_SANITIZE_URL |
|
161 | + ), |
|
162 | + 'telephone' => array( |
|
163 | + 'filter' => FILTER_CALLBACK, |
|
164 | + 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
165 | + ), |
|
166 | + 'faxNumber' => array( |
|
167 | + 'filter' => FILTER_CALLBACK, |
|
168 | + 'options' => '\BOTK\Filters::normalizeItTelephone' |
|
169 | + ), |
|
170 | + 'email' => array( |
|
171 | + 'filter' => FILTER_CALLBACK, |
|
172 | + 'options' => '\BOTK\Filters::normalizeEmail' |
|
173 | + ), |
|
174 | + 'geoDescription' => array( |
|
175 | + 'filter' => FILTER_CALLBACK, |
|
176 | + 'options' => '\BOTK\Filters::normalizeAddress' |
|
177 | + ), |
|
178 | + 'lat' => array( // http://www.regexlib.com/REDetails.aspx?regexp_id=2728 |
|
179 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
180 | + 'options' => array('regexp'=>'/^-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
181 | + ), |
|
182 | + 'long' => array( // http://stackoverflow.com/questions/3518504/regular-expression-for-matching-latitude-longitude-coordinates |
|
183 | + 'filter' => FILTER_VALIDATE_REGEXP, |
|
184 | + 'options' => array('regexp'=>'/-?([1-8]?[0-9]\.{1}\d{1,6}$|90\.{1}0{1,6}$)/') |
|
185 | + ), |
|
186 | + ); |
|
187 | 187 | |
188 | - $localBusiness = new BOTK\Model\LocalBusiness(array(),$options); |
|
189 | - $this->assertEquals($expectedOptions, $localBusiness->getOptions()); |
|
190 | - } |
|
188 | + $localBusiness = new BOTK\Model\LocalBusiness(array(),$options); |
|
189 | + $this->assertEquals($expectedOptions, $localBusiness->getOptions()); |
|
190 | + } |
|
191 | 191 | |
192 | 192 | |
193 | 193 | /** |
194 | 194 | * @dataProvider goodRdf |
195 | 195 | */ |
196 | - public function testRdfGeneration($data, $rdf, $tripleCount) |
|
197 | - { |
|
198 | - $localBusiness = new BOTK\Model\LocalBusiness($data); |
|
199 | - $this->assertEquals($rdf, (string) $localBusiness); |
|
200 | - $this->assertEquals($localBusiness->asTurtle(), (string) $localBusiness, "equivalence with __tostring"); |
|
201 | - $this->assertEquals($tripleCount, $localBusiness->getTripleCount()); |
|
202 | - } |
|
196 | + public function testRdfGeneration($data, $rdf, $tripleCount) |
|
197 | + { |
|
198 | + $localBusiness = new BOTK\Model\LocalBusiness($data); |
|
199 | + $this->assertEquals($rdf, (string) $localBusiness); |
|
200 | + $this->assertEquals($localBusiness->asTurtle(), (string) $localBusiness, "equivalence with __tostring"); |
|
201 | + $this->assertEquals($tripleCount, $localBusiness->getTripleCount()); |
|
202 | + } |
|
203 | 203 | |
204 | - public function goodRdf() |
|
204 | + public function goodRdf() |
|
205 | 205 | { |
206 | - return array( |
|
207 | - array( |
|
208 | - array(), |
|
209 | - '', |
|
210 | - 0, |
|
211 | - ), |
|
212 | - array( |
|
213 | - array( |
|
214 | - 'base' => 'urn:', |
|
215 | - 'id' => 'abc', |
|
216 | - 'vatID' => '01234567890', |
|
217 | - 'legalName' => 'Calenda chiodi snc', |
|
218 | - ), |
|
219 | - '<urn:abc> a schema:Organization;dct:identifier "abc";schema:vatID "01234567890"@it;schema:legalName """CALENDA CHIODI SNC"""@it; . ', |
|
220 | - 4, |
|
221 | - ), |
|
206 | + return array( |
|
207 | + array( |
|
208 | + array(), |
|
209 | + '', |
|
210 | + 0, |
|
211 | + ), |
|
212 | + array( |
|
213 | + array( |
|
214 | + 'base' => 'urn:', |
|
215 | + 'id' => 'abc', |
|
216 | + 'vatID' => '01234567890', |
|
217 | + 'legalName' => 'Calenda chiodi snc', |
|
218 | + ), |
|
219 | + '<urn:abc> a schema:Organization;dct:identifier "abc";schema:vatID "01234567890"@it;schema:legalName """CALENDA CHIODI SNC"""@it; . ', |
|
220 | + 4, |
|
221 | + ), |
|
222 | 222 | |
223 | - array( |
|
224 | - array( |
|
225 | - 'uri' => 'urn:abc', |
|
226 | - 'vatID' => '01234567890', |
|
227 | - 'legalName' => 'Calenda chiodi snc', |
|
228 | - ), |
|
229 | - '<urn:abc> a schema:Organization;schema:vatID "01234567890"@it;schema:legalName """CALENDA CHIODI SNC"""@it; . ', |
|
230 | - 3, |
|
231 | - ), |
|
223 | + array( |
|
224 | + array( |
|
225 | + 'uri' => 'urn:abc', |
|
226 | + 'vatID' => '01234567890', |
|
227 | + 'legalName' => 'Calenda chiodi snc', |
|
228 | + ), |
|
229 | + '<urn:abc> a schema:Organization;schema:vatID "01234567890"@it;schema:legalName """CALENDA CHIODI SNC"""@it; . ', |
|
230 | + 3, |
|
231 | + ), |
|
232 | 232 | |
233 | - array( |
|
234 | - array( |
|
235 | - 'uri' => 'urn:abc', |
|
236 | - 'lat' => '43.23456', |
|
237 | - 'long' => '35.23444', |
|
238 | - ), |
|
239 | - '<urn:abc> a schema:Organization;schema:location <urn:abc_place>; . <geo:43.23456,35.23444> a schema:GeoCoordinates;wgs:lat 43.23456 ;wgs:long 35.23444 ; . <urn:abc_place> a schema:LocalBusiness;schema:geo <geo:43.23456,35.23444>; . ', |
|
240 | - 7, |
|
241 | - ), |
|
242 | - ); |
|
243 | - } |
|
233 | + array( |
|
234 | + array( |
|
235 | + 'uri' => 'urn:abc', |
|
236 | + 'lat' => '43.23456', |
|
237 | + 'long' => '35.23444', |
|
238 | + ), |
|
239 | + '<urn:abc> a schema:Organization;schema:location <urn:abc_place>; . <geo:43.23456,35.23444> a schema:GeoCoordinates;wgs:lat 43.23456 ;wgs:long 35.23444 ; . <urn:abc_place> a schema:LocalBusiness;schema:geo <geo:43.23456,35.23444>; . ', |
|
240 | + 7, |
|
241 | + ), |
|
242 | + ); |
|
243 | + } |
|
244 | 244 | } |
245 | 245 |
@@ -99,7 +99,7 @@ discard block |
||
99 | 99 | |
100 | 100 | public function testGetDefaultOptions() |
101 | 101 | { |
102 | - $options = array ( |
|
102 | + $options = array( |
|
103 | 103 | 'base' => array(), |
104 | 104 | 'lang' => array( |
105 | 105 | 'default' => 'en', |
@@ -108,7 +108,7 @@ discard block |
||
108 | 108 | ), |
109 | 109 | ); |
110 | 110 | |
111 | - $expectedOptions =array ( |
|
111 | + $expectedOptions = array( |
|
112 | 112 | 'base' => array(), |
113 | 113 | 'uri' => array( |
114 | 114 | 'filter' => FILTER_SANITIZE_URL, |
@@ -185,7 +185,7 @@ discard block |
||
185 | 185 | ), |
186 | 186 | ); |
187 | 187 | |
188 | - $localBusiness = new BOTK\Model\LocalBusiness(array(),$options); |
|
188 | + $localBusiness = new BOTK\Model\LocalBusiness(array(), $options); |
|
189 | 189 | $this->assertEquals($expectedOptions, $localBusiness->getOptions()); |
190 | 190 | } |
191 | 191 | |
@@ -198,7 +198,7 @@ discard block |
||
198 | 198 | $localBusiness = new BOTK\Model\LocalBusiness($data); |
199 | 199 | $this->assertEquals($rdf, (string) $localBusiness); |
200 | 200 | $this->assertEquals($localBusiness->asTurtle(), (string) $localBusiness, "equivalence with __tostring"); |
201 | - $this->assertEquals($tripleCount, $localBusiness->getTripleCount()); |
|
201 | + $this->assertEquals($tripleCount, $localBusiness->getTripleCount()); |
|
202 | 202 | } |
203 | 203 | |
204 | 204 | public function goodRdf() |
@@ -3,59 +3,59 @@ |
||
3 | 3 | class FactsFactoryTest extends PHPUnit_Framework_TestCase |
4 | 4 | { |
5 | 5 | |
6 | - public function testMakeLocalBusiness() |
|
7 | - { |
|
8 | - $profile = array( |
|
9 | - 'model' => 'LocalBusiness', |
|
10 | - 'options' => array( |
|
11 | - 'base' => 'urn:test' |
|
12 | - ), |
|
13 | - 'datamapper' => function(array $rawdata){ |
|
14 | - $data = array(); |
|
15 | - $data['id'] = $rawdata[0]; |
|
16 | - $data['legalName'] = $rawdata[2] . ' ' . $rawdata[1]; |
|
17 | - $data['alternateName'] = $rawdata[2]; |
|
18 | - $data['vatID'] = $rawdata[3]; |
|
19 | - $data['email'] = $rawdata[4]; |
|
20 | - $data['addressLocality'] = $rawdata[5]; |
|
21 | - $data['postalCode'] = $rawdata[7]; |
|
22 | - $data['addressRegion'] = $rawdata[8]; |
|
23 | - $data['streetAddress'] = $rawdata[9] . ' ' . $rawdata[10] . ', ' . $rawdata[11]; |
|
24 | - $data['long'] = $rawdata[14]; |
|
25 | - $data['lat'] = $rawdata[15]; |
|
6 | + public function testMakeLocalBusiness() |
|
7 | + { |
|
8 | + $profile = array( |
|
9 | + 'model' => 'LocalBusiness', |
|
10 | + 'options' => array( |
|
11 | + 'base' => 'urn:test' |
|
12 | + ), |
|
13 | + 'datamapper' => function(array $rawdata){ |
|
14 | + $data = array(); |
|
15 | + $data['id'] = $rawdata[0]; |
|
16 | + $data['legalName'] = $rawdata[2] . ' ' . $rawdata[1]; |
|
17 | + $data['alternateName'] = $rawdata[2]; |
|
18 | + $data['vatID'] = $rawdata[3]; |
|
19 | + $data['email'] = $rawdata[4]; |
|
20 | + $data['addressLocality'] = $rawdata[5]; |
|
21 | + $data['postalCode'] = $rawdata[7]; |
|
22 | + $data['addressRegion'] = $rawdata[8]; |
|
23 | + $data['streetAddress'] = $rawdata[9] . ' ' . $rawdata[10] . ', ' . $rawdata[11]; |
|
24 | + $data['long'] = $rawdata[14]; |
|
25 | + $data['lat'] = $rawdata[15]; |
|
26 | 26 | |
27 | - return $data; |
|
28 | - }, |
|
29 | - ); |
|
30 | - $rawdata = array( |
|
31 | - '10042650', |
|
32 | - 'ERBORISTERIA I PRATI DI GIOVANNA MONAMI', |
|
33 | - '', |
|
34 | - '01209991007', |
|
35 | - '', |
|
36 | - 'ROMA', |
|
37 | - 'ROMA', |
|
38 | - '00195', |
|
39 | - 'RM', |
|
40 | - 'VIA', |
|
41 | - 'ANTONIO MORDINI', |
|
42 | - '3', |
|
43 | - '058091', |
|
44 | - '0580912017145', |
|
45 | - '12.464163', |
|
46 | - '41.914001' |
|
47 | - ); |
|
27 | + return $data; |
|
28 | + }, |
|
29 | + ); |
|
30 | + $rawdata = array( |
|
31 | + '10042650', |
|
32 | + 'ERBORISTERIA I PRATI DI GIOVANNA MONAMI', |
|
33 | + '', |
|
34 | + '01209991007', |
|
35 | + '', |
|
36 | + 'ROMA', |
|
37 | + 'ROMA', |
|
38 | + '00195', |
|
39 | + 'RM', |
|
40 | + 'VIA', |
|
41 | + 'ANTONIO MORDINI', |
|
42 | + '3', |
|
43 | + '058091', |
|
44 | + '0580912017145', |
|
45 | + '12.464163', |
|
46 | + '41.914001' |
|
47 | + ); |
|
48 | 48 | |
49 | - $factsFactory = new \BOTK\FactsFactory($profile); |
|
50 | - $facts = $factsFactory->factualize($rawdata); |
|
51 | - $structuredData = $facts->asArray(); |
|
49 | + $factsFactory = new \BOTK\FactsFactory($profile); |
|
50 | + $facts = $factsFactory->factualize($rawdata); |
|
51 | + $structuredData = $facts->asArray(); |
|
52 | 52 | |
53 | - $this->assertInstanceOf('\BOTK\Model\LocalBusiness', $facts); |
|
54 | - $this->assertEquals($structuredData['vatID'], '01209991007'); |
|
55 | - $this->assertEquals($structuredData['id'], '10042650'); |
|
56 | - $this->assertEquals($structuredData['long'], '12.464163'); |
|
57 | - $this->assertEquals($structuredData['streetAddress'], 'VIA ANTONIO MORDINI, 3'); |
|
58 | - } |
|
53 | + $this->assertInstanceOf('\BOTK\Model\LocalBusiness', $facts); |
|
54 | + $this->assertEquals($structuredData['vatID'], '01209991007'); |
|
55 | + $this->assertEquals($structuredData['id'], '10042650'); |
|
56 | + $this->assertEquals($structuredData['long'], '12.464163'); |
|
57 | + $this->assertEquals($structuredData['streetAddress'], 'VIA ANTONIO MORDINI, 3'); |
|
58 | + } |
|
59 | 59 | |
60 | 60 | } |
61 | 61 |
@@ -10,17 +10,17 @@ |
||
10 | 10 | 'options' => array( |
11 | 11 | 'base' => 'urn:test' |
12 | 12 | ), |
13 | - 'datamapper' => function(array $rawdata){ |
|
13 | + 'datamapper' => function(array $rawdata) { |
|
14 | 14 | $data = array(); |
15 | 15 | $data['id'] = $rawdata[0]; |
16 | - $data['legalName'] = $rawdata[2] . ' ' . $rawdata[1]; |
|
16 | + $data['legalName'] = $rawdata[2].' '.$rawdata[1]; |
|
17 | 17 | $data['alternateName'] = $rawdata[2]; |
18 | 18 | $data['vatID'] = $rawdata[3]; |
19 | 19 | $data['email'] = $rawdata[4]; |
20 | 20 | $data['addressLocality'] = $rawdata[5]; |
21 | 21 | $data['postalCode'] = $rawdata[7]; |
22 | 22 | $data['addressRegion'] = $rawdata[8]; |
23 | - $data['streetAddress'] = $rawdata[9] . ' ' . $rawdata[10] . ', ' . $rawdata[11]; |
|
23 | + $data['streetAddress'] = $rawdata[9].' '.$rawdata[10].', '.$rawdata[11]; |
|
24 | 24 | $data['long'] = $rawdata[14]; |
25 | 25 | $data['lat'] = $rawdata[15]; |
26 | 26 |