Skip to content
This repository has been archived by the owner on Nov 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #2 from tenitski/string-class-rename
Browse files Browse the repository at this point in the history
Rename String class due to 'String' being a reserved word in PHP7
  • Loading branch information
Alexei Tenitski committed Jan 26, 2016
2 parents bcf891f + 15af4dd commit 257efda
Show file tree
Hide file tree
Showing 7 changed files with 18 additions and 15 deletions.
3 changes: 3 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,9 @@ language: php
php:
- 5.5
- 5.4
- 5.6
- 7
- hhvm

install:
- composer install
Expand Down
2 changes: 1 addition & 1 deletion src/Formats/String.php → src/Formats/PlainString.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
/**
* The traditional UUID string format
*/
class String implements Format
class PlainString implements Format
{
const FORMAT = '/[0-9A-F]{8}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{4}-[0-9A-F]{12}/i';

Expand Down
2 changes: 1 addition & 1 deletion src/Formats/ReorderedString.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* To retain the 4,2,2,2,6 byte separators, we have to split the node field when
* we move it, and combine the time_mid and time_low fields.
*/
class ReorderedString extends String
class ReorderedString extends PlainString
{
/**
* @inheritDoc
Expand Down
4 changes: 2 additions & 2 deletions src/Uuid.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

use InvalidArgumentException;
use MysqlUuid\Formats\Format;
use MysqlUuid\Formats\String;
use MysqlUuid\Formats\PlainString;

/**
* MySQL UUID format utilities
Expand Down Expand Up @@ -39,7 +39,7 @@ public function __construct($value, Format $format = null)
if ($format) {
$this->format = $format;
} else {
$this->format = new String();
$this->format = new PlainString();
}
}

Expand Down
12 changes: 6 additions & 6 deletions test/MysqlUuid/ConvertTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
use MysqlUuid\Formats\Format;
use MysqlUuid\Formats\Hex;
use MysqlUuid\Formats\ReorderedString;
use MysqlUuid\Formats\String;
use MysqlUuid\Formats\PlainString;
use MysqlUuid\Test\BaseTest;

class ConvertTest extends BaseTest
Expand Down Expand Up @@ -62,8 +62,8 @@ public function testConvert()
protected function getFormat($format)
{
switch ($format) {
case 'string':
return new String();
case 'plain':
return new PlainString();
case 'reordered':
return new ReorderedString();
case 'binary':
Expand All @@ -77,23 +77,23 @@ protected function conversions()
{
return [
[
'from' => 'string',
'from' => 'plain',
'to' => 'reordered',
'cases' => [
'b8e2adff-0331-11e4-9583-080027f3add4' => '080027f3-add4-11e4-9583-0331b8e2adff',
'b8fc7a3e-0331-11e4-9583-080027f3add4' => '080027f3-add4-11e4-9583-0331b8fc7a3e'
],
],
[
'from' => 'string',
'from' => 'plain',
'to' => 'hex',
'cases' => [
'b8e2adff-0331-11e4-9583-080027f3add4' => 'b8e2adff033111e49583080027f3add4',
'b8fc7a3e-0331-11e4-9583-080027f3add4' => 'b8fc7a3e033111e49583080027f3add4'
],
],
[
'from' => 'string',
'from' => 'plain',
'to' => 'binary',
'cases' => [
'b8e2adff-0331-11e4-9583-080027f3add4' => "\x08\x00\x27\xf3\xad\xd4\x95\x83\x11\xe4\x03\x31\xb8\xe2\xad\xff",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,14 @@

namespace MysqlUuid\Formats;

class StringTest extends FormatTest
class PlainStringTest extends FormatTest
{
/**
* @return Format
*/
protected function getSut()
{
return new String();
return new PlainString();
}

protected function good()
Expand Down
6 changes: 3 additions & 3 deletions test/MysqlUuid/UuidTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

namespace MysqlUuid;

use MysqlUuid\Formats\String;
use MysqlUuid\Formats\PlainString;
use MysqlUuid\Test\BaseTest;

class UuidTest extends BaseTest
Expand Down Expand Up @@ -30,7 +30,7 @@ public function testBadFormat()
->will($this->returnValue(null));

$uuid = new Uuid('b8fc7a3e-0331-11e4-9583-080027f3add4', $format);
$uuid->toFormat(new String());
$uuid->toFormat(new PlainString());
}

public function testFieldCrud()
Expand All @@ -42,6 +42,6 @@ public function testFieldCrud()

$uuid->setField('clock_seq', 'ffff');

$this->assertEquals($uuid->toFormat(new String()), 'b8fc7a3e-0331-11e4-ffff-080027f3add4');
$this->assertEquals($uuid->toFormat(new PlainString()), 'b8fc7a3e-0331-11e4-ffff-080027f3add4');
}
}

0 comments on commit 257efda

Please sign in to comment.