@@ -26,35 +26,35 @@ |
||
26 | 26 | |
27 | 27 | $data = [ |
28 | 28 | Relation::EQUAL => function ($field, $value) { |
29 | - return $field . "=" . $value; |
|
29 | + return $field . "=" . $value; |
|
30 | 30 | }, |
31 | 31 | |
32 | 32 | Relation::GREATER_THAN => function ($field, $value) { |
33 | - return $field . ">" . $value; |
|
33 | + return $field . ">" . $value; |
|
34 | 34 | }, |
35 | 35 | |
36 | 36 | Relation::LESS_THAN => function ($field, $value) { |
37 | - return $field . "<" . $value; |
|
37 | + return $field . "<" . $value; |
|
38 | 38 | }, |
39 | 39 | |
40 | 40 | Relation::GREATER_OR_EQUAL_THAN => function ($field, $value) { |
41 | - return $field . ">=" . $value; |
|
41 | + return $field . ">=" . $value; |
|
42 | 42 | }, |
43 | 43 | |
44 | 44 | Relation::LESS_OR_EQUAL_THAN => function ($field, $value) { |
45 | - return $field . "<=" . $value; |
|
45 | + return $field . "<=" . $value; |
|
46 | 46 | }, |
47 | 47 | |
48 | 48 | Relation::NOT_EQUAL => function ($field, $value) { |
49 | - return $field . "!=" . $value; |
|
49 | + return $field . "!=" . $value; |
|
50 | 50 | }, |
51 | 51 | |
52 | 52 | Relation::STARTS_WITH => function ($field, $value) { |
53 | - return " starts-with($field, $value) "; |
|
53 | + return " starts-with($field, $value) "; |
|
54 | 54 | }, |
55 | 55 | |
56 | 56 | Relation::CONTAINS => function ($field, $value) { |
57 | - return " contains($field, $value) "; |
|
57 | + return " contains($field, $value) "; |
|
58 | 58 | }, |
59 | 59 | ]; |
60 | 60 |
@@ -15,45 +15,45 @@ |
||
15 | 15 | return "/anydataset/row"; |
16 | 16 | } |
17 | 17 | |
18 | - return "/anydataset/row[" . $xpathFilter . "]"; |
|
18 | + return "/anydataset/row[".$xpathFilter."]"; |
|
19 | 19 | } |
20 | 20 | |
21 | 21 | public function getRelation($name, $relation, $value, &$param) |
22 | 22 | { |
23 | 23 | $str = is_numeric($value) ? "" : "'"; |
24 | - $field = "field[@name='" . $name . "'] "; |
|
24 | + $field = "field[@name='".$name."'] "; |
|
25 | 25 | $value = " $str$value$str "; |
26 | 26 | |
27 | 27 | $data = [ |
28 | - Relation::EQUAL => function ($field, $value) { |
|
29 | - return $field . "=" . $value; |
|
28 | + Relation::EQUAL => function($field, $value) { |
|
29 | + return $field."=".$value; |
|
30 | 30 | }, |
31 | 31 | |
32 | - Relation::GREATER_THAN => function ($field, $value) { |
|
33 | - return $field . ">" . $value; |
|
32 | + Relation::GREATER_THAN => function($field, $value) { |
|
33 | + return $field.">".$value; |
|
34 | 34 | }, |
35 | 35 | |
36 | - Relation::LESS_THAN => function ($field, $value) { |
|
37 | - return $field . "<" . $value; |
|
36 | + Relation::LESS_THAN => function($field, $value) { |
|
37 | + return $field."<".$value; |
|
38 | 38 | }, |
39 | 39 | |
40 | - Relation::GREATER_OR_EQUAL_THAN => function ($field, $value) { |
|
41 | - return $field . ">=" . $value; |
|
40 | + Relation::GREATER_OR_EQUAL_THAN => function($field, $value) { |
|
41 | + return $field.">=".$value; |
|
42 | 42 | }, |
43 | 43 | |
44 | - Relation::LESS_OR_EQUAL_THAN => function ($field, $value) { |
|
45 | - return $field . "<=" . $value; |
|
44 | + Relation::LESS_OR_EQUAL_THAN => function($field, $value) { |
|
45 | + return $field."<=".$value; |
|
46 | 46 | }, |
47 | 47 | |
48 | - Relation::NOT_EQUAL => function ($field, $value) { |
|
49 | - return $field . "!=" . $value; |
|
48 | + Relation::NOT_EQUAL => function($field, $value) { |
|
49 | + return $field."!=".$value; |
|
50 | 50 | }, |
51 | 51 | |
52 | - Relation::STARTS_WITH => function ($field, $value) { |
|
52 | + Relation::STARTS_WITH => function($field, $value) { |
|
53 | 53 | return " starts-with($field, $value) "; |
54 | 54 | }, |
55 | 55 | |
56 | - Relation::CONTAINS => function ($field, $value) { |
|
56 | + Relation::CONTAINS => function($field, $value) { |
|
57 | 57 | return " contains($field, $value) "; |
58 | 58 | }, |
59 | 59 | ]; |
@@ -72,35 +72,35 @@ |
||
72 | 72 | } |
73 | 73 | |
74 | 74 | $data = [ |
75 | - Relation::EQUAL => function ($valueparam, $value) { |
|
75 | + Relation::EQUAL => function($valueparam, $value) { |
|
76 | 76 | return ($valueparam == $value); |
77 | 77 | }, |
78 | 78 | |
79 | - Relation::GREATER_THAN => function ($valueparam, $value) { |
|
79 | + Relation::GREATER_THAN => function($valueparam, $value) { |
|
80 | 80 | return ($valueparam > $value); |
81 | 81 | }, |
82 | 82 | |
83 | - Relation::LESS_THAN => function ($valueparam, $value) { |
|
83 | + Relation::LESS_THAN => function($valueparam, $value) { |
|
84 | 84 | return ($valueparam < $value); |
85 | 85 | }, |
86 | 86 | |
87 | - Relation::GREATER_OR_EQUAL_THAN => function ($valueparam, $value) { |
|
87 | + Relation::GREATER_OR_EQUAL_THAN => function($valueparam, $value) { |
|
88 | 88 | return ($valueparam >= $value); |
89 | 89 | }, |
90 | 90 | |
91 | - Relation::LESS_OR_EQUAL_THAN => function ($valueparam, $value) { |
|
91 | + Relation::LESS_OR_EQUAL_THAN => function($valueparam, $value) { |
|
92 | 92 | return ($valueparam <= $value); |
93 | 93 | }, |
94 | 94 | |
95 | - Relation::NOT_EQUAL => function ($valueparam, $value) { |
|
95 | + Relation::NOT_EQUAL => function($valueparam, $value) { |
|
96 | 96 | return ($valueparam != $value); |
97 | 97 | }, |
98 | 98 | |
99 | - Relation::STARTS_WITH => function ($valueparam, $value) { |
|
99 | + Relation::STARTS_WITH => function($valueparam, $value) { |
|
100 | 100 | return (strpos($valueparam, $value) === 0); |
101 | 101 | }, |
102 | 102 | |
103 | - Relation::CONTAINS => function ($valueparam, $value) { |
|
103 | + Relation::CONTAINS => function($valueparam, $value) { |
|
104 | 104 | return (strpos($valueparam, $value) !== false); |
105 | 105 | }, |
106 | 106 | ]; |
@@ -13,7 +13,6 @@ discard block |
||
13 | 13 | * Anydataset files have extension ".anydata.xml" and have many classes to put and get data into anydataset xml file. |
14 | 14 | * Anydataset class just read and write files. To search elements you need use AnyIterator |
15 | 15 | * and IteratorFilter. Each row have a class Row. |
16 | - |
|
17 | 16 | * XML Structure |
18 | 17 | * <code> |
19 | 18 | * <anydataset> |
@@ -28,17 +27,14 @@ discard block |
||
28 | 27 | * </row> |
29 | 28 | * </anydataset> |
30 | 29 | * </code> |
31 | - |
|
32 | 30 | * How to use: |
33 | 31 | * <code> |
34 | 32 | * $any = new AnyDataset(); |
35 | 33 | * </code> |
36 | - |
|
37 | 34 | * |
38 | 35 | *@see Row |
39 | 36 | * @see AnyIterator |
40 | 37 | * @see IteratorFilter |
41 | - |
|
42 | 38 | */ |
43 | 39 | class AnyDataset |
44 | 40 | { |
@@ -73,7 +73,7 @@ discard block |
||
73 | 73 | $this->currentRow = -1; |
74 | 74 | |
75 | 75 | $this->filename = null; |
76 | - $this->defineSavePath($filename, function () { |
|
76 | + $this->defineSavePath($filename, function() { |
|
77 | 77 | if (!is_null($this->filename)) { |
78 | 78 | $this->createFrom($this->filename); |
79 | 79 | } |
@@ -122,7 +122,7 @@ discard block |
||
122 | 122 | foreach ($fields as $field) { |
123 | 123 | $attr = $field->attributes->getNamedItem("name"); |
124 | 124 | if (is_null($attr)) { |
125 | - throw new InvalidArgumentException('Malformed anydataset file ' . basename($filepath)); |
|
125 | + throw new InvalidArgumentException('Malformed anydataset file '.basename($filepath)); |
|
126 | 126 | } |
127 | 127 | |
128 | 128 | $sr->addField($attr->nodeValue, $field->nodeValue); |
@@ -152,7 +152,7 @@ discard block |
||
152 | 152 | */ |
153 | 153 | public function save($filename = null) |
154 | 154 | { |
155 | - $this->defineSavePath($filename, function () { |
|
155 | + $this->defineSavePath($filename, function() { |
|
156 | 156 | if (is_null($this->filename)) { |
157 | 157 | throw new DatabaseException("No such file path to save anydataset"); |
158 | 158 | } |
@@ -329,7 +329,7 @@ discard block |
||
329 | 329 | $left = $right = array(); |
330 | 330 | |
331 | 331 | $cntSeq = count($seq); |
332 | - for ($i = 1; $i < $cntSeq; $i ++) { |
|
332 | + for ($i = 1; $i < $cntSeq; $i++) { |
|
333 | 333 | if ($seq[$i]->get($field) <= $key->get($field)) { |
334 | 334 | $left[] = $seq[$i]; |
335 | 335 | } else { |
@@ -339,7 +339,7 @@ discard block |
||
339 | 339 | |
340 | 340 | return array_merge( |
341 | 341 | $this->quickSortExec($left, $field), |
342 | - [ $key ], |
|
342 | + [$key], |
|
343 | 343 | $this->quickSortExec($right, $field) |
344 | 344 | ); |
345 | 345 | } |
@@ -7,10 +7,10 @@ discard block |
||
7 | 7 | { |
8 | 8 | protected $fieldValidator = []; |
9 | 9 | |
10 | - const REQUIRED="required"; |
|
11 | - const NUMBER="number"; |
|
12 | - const REGEX="regex"; |
|
13 | - const CUSTOM="custom"; |
|
10 | + const REQUIRED = "required"; |
|
11 | + const NUMBER = "number"; |
|
12 | + const REGEX = "regex"; |
|
13 | + const CUSTOM = "custom"; |
|
14 | 14 | |
15 | 15 | protected function setProperty($fieldList, $property, $value) |
16 | 16 | { |
@@ -18,7 +18,7 @@ discard block |
||
18 | 18 | if (!isset($this->fieldValidator[$field])) { |
19 | 19 | $this->fieldValidator[$field] = []; |
20 | 20 | } |
21 | - $this->fieldValidator[$field] = [ $property => $value ]; |
|
21 | + $this->fieldValidator[$field] = [$property => $value]; |
|
22 | 22 | } |
23 | 23 | } |
24 | 24 | |
@@ -67,7 +67,7 @@ discard block |
||
67 | 67 | { |
68 | 68 | $result = null; |
69 | 69 | if (isset($properties[self::CUSTOM]) && $properties[self::CUSTOM] instanceof Closure) { |
70 | - $result = $properties[self::CUSTOM]($value); |
|
70 | + $result = $properties[self::CUSTOM]($value); |
|
71 | 71 | } |
72 | 72 | return empty($result) ? null : $result; |
73 | 73 | } |
@@ -24,10 +24,10 @@ |
||
24 | 24 | $data = $this->fieldList[$field]; |
25 | 25 | |
26 | 26 | switch ($data[0]) { |
27 | - case self::FORMAT: |
|
28 | - return $this->formatPattern($row, $field, $data[1]); |
|
29 | - case self::CUSTOM: |
|
30 | - return $this->formatCustom($row, $field, $data[1]); |
|
27 | + case self::FORMAT: |
|
28 | + return $this->formatPattern($row, $field, $data[1]); |
|
29 | + case self::CUSTOM: |
|
30 | + return $this->formatCustom($row, $field, $data[1]); |
|
31 | 31 | } |
32 | 32 | } |
33 | 33 |
@@ -42,7 +42,7 @@ discard block |
||
42 | 42 | { |
43 | 43 | $rowParsed = $row->toArray(); |
44 | 44 | foreach ($rowParsed as $key => $value) { |
45 | - $rowParsed['{' . $key . '}'] = $value; |
|
45 | + $rowParsed['{'.$key.'}'] = $value; |
|
46 | 46 | unset($rowParsed[$key]); |
47 | 47 | } |
48 | 48 | |
@@ -61,7 +61,7 @@ discard block |
||
61 | 61 | */ |
62 | 62 | public function addFormat($field, $pattern) |
63 | 63 | { |
64 | - $this->fieldList[$field] = [ self::FORMAT, $pattern ]; |
|
64 | + $this->fieldList[$field] = [self::FORMAT, $pattern]; |
|
65 | 65 | return $this; |
66 | 66 | } |
67 | 67 | |
@@ -74,7 +74,7 @@ discard block |
||
74 | 74 | */ |
75 | 75 | public function addCustomFormat($field, Closure $closure) |
76 | 76 | { |
77 | - $this->fieldList[$field] = [ self::CUSTOM, $closure ]; |
|
77 | + $this->fieldList[$field] = [self::CUSTOM, $closure]; |
|
78 | 78 | return $this; |
79 | 79 | } |
80 | 80 | } |
81 | 81 | \ No newline at end of file |