Skip to content

Commit

Permalink
Merge branch 'bug/map'
Browse files Browse the repository at this point in the history
  • Loading branch information
cambell-prince committed Mar 1, 2019
2 parents 652d130 + 8d6f970 commit bd7833f
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/DataMapper.php
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public static function autoTable($c)
public static function splitUpper($s)
{
$matches = array();
$matchCount = preg_match_all('/[A-Z][a-z]*/', $s, $matches);
$matchCount = preg_match_all('/[A-Z][a-z0-9]*/', $s, $matches);
if ($matchCount > 0) {
return $matches[0];
}
Expand All @@ -80,7 +80,7 @@ public static function splitUpper($s)
public static function propertyName($s)
{
$matches = array();
$matchCount = preg_match_all('/^([a-z]+)((?:[A-Z][a-z]*)*)/', $s, $matches);
$matchCount = preg_match_all('/^([a-z0-9]+)((?:[A-Z][a-z0-9]*)*)/', $s, $matches);
$propertyName = '';
if ($matchCount == 1 && count($matches) == 3) {
$propertyName .= strtolower($matches[1][0]);
Expand Down Expand Up @@ -211,7 +211,7 @@ public function delete($id)
return $result->rowCount() >= 1;
}

public static function find($creatable, \PDO $pdo)
public static function find($creatable, $pdo)
{
return new QueryBuilder($creatable, $pdo);
}
Expand Down
12 changes: 12 additions & 0 deletions test/anorm/DataMapper_Test.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,18 @@ function testPropertyName_TwoWords_OK()
$this->assertEquals('test_two_three_four', $name);
}

function testPropertyName_EndsWithDigit_OK()
{
$name = DataMapper::propertyName('test1');
$this->assertEquals('test1', $name);
}

function testPropertyName_TwoWordsEndsWithDigit_OK()
{
$name = DataMapper::propertyName('testTwo1');
$this->assertEquals('test_two1', $name);
}

function testAutoMap_TestClass_OK()
{
$actual = DataMapper::autoMap(new TestClassModel());
Expand Down

0 comments on commit bd7833f

Please sign in to comment.