Skip to content

Commit

Permalink
Case insensitive type checking in reader
Browse files Browse the repository at this point in the history
  • Loading branch information
florianeckerstorfer committed Mar 16, 2018
1 parent f6a9081 commit f6e3bc7
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/Reader.php
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ protected function parseColumns(Document $document, array $lines)
if (preg_match('/ATTRIBUTE\s([a-zA-Z0-9_-]+)\s(.*)/i', $line, $matches)) {
$type = $matches[2];
$column = null;
if ($type === 'string') {
if (strcasecmp($type, 'string') === 0) {
$column = new StringColumn($matches[1]);
} else if ($type === 'numeric') {
} else if (strcasecmp($type, 'numeric') === 0) {
$column = new NumericColumn($matches[1]);
} else if (preg_match('/^\{(.*)\}$/', $matches[2], $classMatches)) {
$column = new NominalColumn($matches[1], array_map(function ($value) {
Expand Down
5 changes: 5 additions & 0 deletions tests/ReaderTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,8 @@ public function readRelationName()
@ATTRIBUTE b numeric
@ATTRIBUTE c {x,y,'Top 100 Editors Picks: Print Books: Books'}
@ATTRIBUTE d date "yyyy-MM-dd HH:mm:ss"
@ATTRIBUTE e String
@ATTRIBUTE f Numeric
@DATA
hello,1.5,x,'2015-07-17 16:12:30'
Expand All @@ -48,6 +50,9 @@ public function readRelationName()
$this->assertEquals('b', $columns['b']->getName());
$this->assertEquals('numeric', $columns['b']->getType());

$this->assertEquals('string', $columns['e']->getType());
$this->assertEquals('numeric', $columns['f']->getType());

/** @var NominalColumn $columnC */
$columnC = $columns['c'];
$this->assertEquals('c', $columnC->getName());
Expand Down

0 comments on commit f6e3bc7

Please sign in to comment.