From 2e267dc1952fa65bfce9ca0281c7c7701fc586fc Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 14 Feb 2014 16:50:30 +1000 Subject: [PATCH 1/6] Implemented memberOrNullBy and variants. Closes #18. --- src/AbstractMultiton.php | 115 +++++++++++++++-------- src/AbstractValueMultiton.php | 42 ++++++--- test/suite/AbstractEnumerationTest.php | 56 ++++++++--- test/suite/AbstractMultitonTest.php | 66 ++++++++----- test/suite/AbstractValueMultitonTest.php | 89 +++++++++++------- 5 files changed, 241 insertions(+), 127 deletions(-) diff --git a/src/AbstractMultiton.php b/src/AbstractMultiton.php index fff55b1..3c6c4c9 100644 --- a/src/AbstractMultiton.php +++ b/src/AbstractMultiton.php @@ -19,22 +19,6 @@ */ abstract class AbstractMultiton implements MultitonInterface { - /** - * Returns an array of all members in this multiton. - * - * @return array All members. - */ - final public static function members() - { - $class = get_called_class(); - if (!array_key_exists($class, self::$members)) { - self::$members[$class] = array(); - static::initializeMembers(); - } - - return self::$members[$class]; - } - /** * Returns a single member by string key. * @@ -147,41 +131,40 @@ function (MultitonInterface $member) use ( } /** - * Returns a set of members by comparison with the result of an accessor - * method. + * Returns a single member by comparison with the result of an accessor + * method. Additionally returns null if the supplied value is null. * * @param string $property The name of the property (accessor method) to match. - * @param mixed $value The value to match. + * @param mixed $value The value to match, or null. * @param boolean|null $isCaseSensitive True if the search should be case sensitive. * - * @return array All members for which $member->{$property}() === $value. + * @return MultitonInterface|null The first member for which $member->{$property}() === $value, or null if the supplied value is null. + * @throws Exception\UndefinedMemberExceptionInterface If no associated member is found. */ - final public static function membersBy( + final public static function memberOrNullBy( $property, $value, $isCaseSensitive = null ) { - if (null === $isCaseSensitive) { - $isCaseSensitive = true; - } - if (!$isCaseSensitive && is_scalar($value)) { - $value = strtoupper(strval($value)); - } + $member = static::memberByWithDefault( + $property, + $value, + null, + $isCaseSensitive + ); + if (null === $member) { + if (null === $value) { + return null; + } - return static::membersByPredicate( - function (MultitonInterface $member) use ( + throw static::createUndefinedMemberException( + get_called_class(), $property, - $value, - $isCaseSensitive - ) { - $memberValue = $member->{$property}(); - if (!$isCaseSensitive && is_scalar($memberValue)) { - $memberValue = strtoupper(strval($memberValue)); - } + $value + ); + } - return $memberValue === $value; - } - ); + return $member; } /** @@ -228,6 +211,60 @@ final public static function memberByPredicateWithDefault( return $default; } + /** + * Returns an array of all members in this multiton. + * + * @return array All members. + */ + final public static function members() + { + $class = get_called_class(); + if (!array_key_exists($class, self::$members)) { + self::$members[$class] = array(); + static::initializeMembers(); + } + + return self::$members[$class]; + } + + /** + * Returns a set of members by comparison with the result of an accessor + * method. + * + * @param string $property The name of the property (accessor method) to match. + * @param mixed $value The value to match. + * @param boolean|null $isCaseSensitive True if the search should be case sensitive. + * + * @return array All members for which $member->{$property}() === $value. + */ + final public static function membersBy( + $property, + $value, + $isCaseSensitive = null + ) { + if (null === $isCaseSensitive) { + $isCaseSensitive = true; + } + if (!$isCaseSensitive && is_scalar($value)) { + $value = strtoupper(strval($value)); + } + + return static::membersByPredicate( + function (MultitonInterface $member) use ( + $property, + $value, + $isCaseSensitive + ) { + $memberValue = $member->{$property}(); + if (!$isCaseSensitive && is_scalar($memberValue)) { + $memberValue = strtoupper(strval($memberValue)); + } + + return $memberValue === $value; + } + ); + } + /** * Returns a set of members by predicate callback. * diff --git a/src/AbstractValueMultiton.php b/src/AbstractValueMultiton.php index ead96ed..7404456 100644 --- a/src/AbstractValueMultiton.php +++ b/src/AbstractValueMultiton.php @@ -31,19 +31,6 @@ final public static function memberByValue($value, $isCaseSensitive = null) return static::memberBy('value', $value, $isCaseSensitive); } - /** - * Returns a set of members matching the supplied value. - * - * @param scalar $value The value associated with the members. - * @param boolean|null $isCaseSensitive True if the search should be case sensitive. - * - * @return array All members with the supplied value. - */ - final public static function membersByValue($value, $isCaseSensitive = null) - { - return static::membersBy('value', $value, $isCaseSensitive); - } - /** * Returns a single member by value. Additionally returns a default if no * associated member is found. @@ -67,6 +54,35 @@ final public static function memberByValueWithDefault( ); } + /** + * Returns a single member by value. + * + * @param scalar|null $value The value associated with the member, or null. + * @param boolean|null $isCaseSensitive True if the search should be case sensitive. + * + * @return ValueMultitonInterface|null The first member with the supplied value, or null if the supplied value is null. + * @throws Exception\UndefinedMemberException If no associated member is found. + */ + final public static function memberOrNullByValue( + $value, + $isCaseSensitive = null + ) { + return static::memberOrNullBy('value', $value, $isCaseSensitive); + } + + /** + * Returns a set of members matching the supplied value. + * + * @param scalar $value The value associated with the members. + * @param boolean|null $isCaseSensitive True if the search should be case sensitive. + * + * @return array All members with the supplied value. + */ + final public static function membersByValue($value, $isCaseSensitive = null) + { + return static::membersBy('value', $value, $isCaseSensitive); + } + /** * Returns the value of this member. * diff --git a/test/suite/AbstractEnumerationTest.php b/test/suite/AbstractEnumerationTest.php index 20d3389..b71f116 100644 --- a/test/suite/AbstractEnumerationTest.php +++ b/test/suite/AbstractEnumerationTest.php @@ -30,15 +30,6 @@ protected function setUp() // Multiton tests ========================================================== - public function testMembers() - { - $this->assertSame(array( - 'BAZ' => ValidEnumeration::BAZ(), - 'FOO' => ValidEnumeration::FOO(), - 'BAR' => ValidEnumeration::BAR(), - ), ValidEnumeration::members()); - } - public function testMemberByKey() { $foo = ValidEnumeration::memberByKey('FOO'); @@ -101,13 +92,18 @@ public function testMemberByWithDefault() $this->assertNull(ValidEnumeration::memberByWithDefault('key', 'qux')); } - public function testMembersBy() + public function testMemberOrNullBy() { - $foo = ValidEnumeration::membersBy('value', 'oof'); - $bar = ValidEnumeration::membersBy('value', 'RAB', false); + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullBy('key', 'FOO')); + $this->assertSame(ValidEnumeration::BAR(), ValidEnumeration::memberOrNullBy('key', 'BAR')); + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullBy('key', 'Foo', false)); + $this->assertNull(ValidEnumeration::memberOrNullBy('key', null)); + } - $this->assertSame(array('FOO' => ValidEnumeration::FOO()), $foo); - $this->assertSame(array('BAR' => ValidEnumeration::BAR()), $bar); + public function testMemberOrNullByFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidEnumeration::memberOrNullBy('key', 'DOOM'); } public function testMemberByPredicate() @@ -170,6 +166,24 @@ function (ValidEnumeration $member) { $this->assertNull($defaultNull); } + public function testMembers() + { + $this->assertSame(array( + 'BAZ' => ValidEnumeration::BAZ(), + 'FOO' => ValidEnumeration::FOO(), + 'BAR' => ValidEnumeration::BAR(), + ), ValidEnumeration::members()); + } + + public function testMembersBy() + { + $foo = ValidEnumeration::membersBy('value', 'oof'); + $bar = ValidEnumeration::membersBy('value', 'RAB', false); + + $this->assertSame(array('FOO' => ValidEnumeration::FOO()), $foo); + $this->assertSame(array('BAR' => ValidEnumeration::BAR()), $bar); + } + public function testMembersByPredicate() { $notBaz = ValidEnumeration::membersByPredicate( @@ -280,6 +294,20 @@ public function testMemberByValueWithDefault() $this->assertNull(ValidEnumeration::memberByValueWithDefault('qux')); } + public function testMemberOrNullByValue() + { + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullByValue('oof')); + $this->assertSame(ValidEnumeration::BAR(), ValidEnumeration::memberOrNullByValue('rab')); + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullByValue('Oof', false)); + $this->assertNull(ValidEnumeration::memberOrNullByValue(null)); + } + + public function testMemberOrNullByValueFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidEnumeration::memberOrNullByValue('mood'); + } + public function testMembersByValue() { $this->assertSame(array('FOO' => ValidEnumeration::FOO()), ValidEnumeration::membersByValue('oof')); diff --git a/test/suite/AbstractMultitonTest.php b/test/suite/AbstractMultitonTest.php index a3a9bf8..7461f3a 100644 --- a/test/suite/AbstractMultitonTest.php +++ b/test/suite/AbstractMultitonTest.php @@ -32,18 +32,6 @@ protected function setUp() // Multiton tests ========================================================== - public function testMembers() - { - $this->assertSame( - array( - 'FOO' => ValidMultiton::FOO(), - 'BAR' => ValidMultiton::BAR(), - 'BAZ' => ValidMultiton::BAZ(), - ), - ValidMultiton::members() - ); - } - public function testMemberByKey() { $this->assertSame(array(), ValidMultiton::calls()); @@ -118,22 +106,18 @@ public function testMemberByWithDefault() $this->assertNull(ValidMultiton::memberByWithDefault('key', 'qux')); } - public function testMembersBy() + public function testMemberOrNullBy() { - $this->assertSame(array(), ValidMultiton::calls()); - - $foo = ValidMultiton::membersBy('value', 'oof'); - $bar = ValidMultiton::membersBy('value', 'RAB', false); - - $this->assertSame(array('FOO' => ValidMultiton::FOO()), $foo); - $this->assertSame(array('BAR' => ValidMultiton::BAR()), $bar); + $this->assertSame(ValidMultiton::FOO(), ValidMultiton::memberOrNullBy('key', 'FOO')); + $this->assertSame(ValidMultiton::BAR(), ValidMultiton::memberOrNullBy('key', 'BAR')); + $this->assertSame(ValidMultiton::FOO(), ValidMultiton::memberOrNullBy('key', 'Foo', false)); + $this->assertNull(ValidMultiton::memberOrNullBy('key', null)); + } - $this->assertSame(array( - array( - 'Eloquent\Enumeration\Test\Fixture\ValidMultiton::initializeMembers', - array(), - ), - ), ValidMultiton::calls()); + public function testMemberOrNullByFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidMultiton::memberOrNullBy('key', 'DOOM'); } public function testMemberByPredicate() @@ -205,6 +189,36 @@ function (ValidMultiton $member) { $this->assertNull($defaultNull); } + public function testMembers() + { + $this->assertSame( + array( + 'FOO' => ValidMultiton::FOO(), + 'BAR' => ValidMultiton::BAR(), + 'BAZ' => ValidMultiton::BAZ(), + ), + ValidMultiton::members() + ); + } + + public function testMembersBy() + { + $this->assertSame(array(), ValidMultiton::calls()); + + $foo = ValidMultiton::membersBy('value', 'oof'); + $bar = ValidMultiton::membersBy('value', 'RAB', false); + + $this->assertSame(array('FOO' => ValidMultiton::FOO()), $foo); + $this->assertSame(array('BAR' => ValidMultiton::BAR()), $bar); + + $this->assertSame(array( + array( + 'Eloquent\Enumeration\Test\Fixture\ValidMultiton::initializeMembers', + array(), + ), + ), ValidMultiton::calls()); + } + public function testMembersByPredicate() { $this->assertSame(array(), ValidMultiton::calls()); diff --git a/test/suite/AbstractValueMultitonTest.php b/test/suite/AbstractValueMultitonTest.php index 8da4798..10645b2 100644 --- a/test/suite/AbstractValueMultitonTest.php +++ b/test/suite/AbstractValueMultitonTest.php @@ -32,15 +32,6 @@ protected function setUp() // Multiton tests ========================================================== - public function testMembers() - { - $this->assertSame(array( - 'FOO' => ValidValueMultiton::FOO(), - 'BAR' => ValidValueMultiton::BAR(), - 'BAZ' => ValidValueMultiton::BAZ(), - ), ValidValueMultiton::members()); - } - public function testMemberByKey() { $this->assertSame(array(), ValidValueMultiton::calls()); @@ -115,22 +106,18 @@ public function testMemberByWithDefault() $this->assertNull(ValidValueMultiton::memberByWithDefault('key', 'qux')); } - public function testMembersBy() + public function testMemberOrNullBy() { - $this->assertSame(array(), ValidValueMultiton::calls()); - - $foo = ValidValueMultiton::membersBy('value', 'oof'); - $bar = ValidValueMultiton::membersBy('value', 'RAB', false); - - $this->assertSame(array('FOO' => ValidValueMultiton::FOO()), $foo); - $this->assertSame(array('BAR' => ValidValueMultiton::BAR()), $bar); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullBy('key', 'FOO')); + $this->assertSame(ValidValueMultiton::BAR(), ValidValueMultiton::memberOrNullBy('key', 'BAR')); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullBy('key', 'Foo', false)); + $this->assertNull(ValidValueMultiton::memberOrNullBy('key', null)); + } - $this->assertSame(array( - array( - 'Eloquent\Enumeration\Test\Fixture\ValidValueMultiton::initializeMembers', - array(), - ), - ), ValidValueMultiton::calls()); + public function testMemberOrNullByFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidValueMultiton::memberOrNullBy('key', 'DOOM'); } public function testMemberByPredicate() @@ -202,6 +189,33 @@ function (ValidValueMultiton $member) { $this->assertNull($defaultNull); } + public function testMembers() + { + $this->assertSame(array( + 'FOO' => ValidValueMultiton::FOO(), + 'BAR' => ValidValueMultiton::BAR(), + 'BAZ' => ValidValueMultiton::BAZ(), + ), ValidValueMultiton::members()); + } + + public function testMembersBy() + { + $this->assertSame(array(), ValidValueMultiton::calls()); + + $foo = ValidValueMultiton::membersBy('value', 'oof'); + $bar = ValidValueMultiton::membersBy('value', 'RAB', false); + + $this->assertSame(array('FOO' => ValidValueMultiton::FOO()), $foo); + $this->assertSame(array('BAR' => ValidValueMultiton::BAR()), $bar); + + $this->assertSame(array( + array( + 'Eloquent\Enumeration\Test\Fixture\ValidValueMultiton::initializeMembers', + array(), + ), + ), ValidValueMultiton::calls()); + } + public function testMembersByPredicate() { $this->assertSame(array(), ValidValueMultiton::calls()); @@ -309,18 +323,9 @@ public function testMemberByValueFailureUndefined() public function testMemberByValueWithDefault() { - $this->assertSame( - ValidValueMultiton::FOO(), - ValidValueMultiton::memberByValueWithDefault('oof') - ); - $this->assertSame( - ValidValueMultiton::BAR(), - ValidValueMultiton::memberByValueWithDefault('rab') - ); - $this->assertSame( - ValidValueMultiton::FOO(), - ValidValueMultiton::memberByValueWithDefault('Oof', null, false) - ); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberByValueWithDefault('oof')); + $this->assertSame(ValidValueMultiton::BAR(), ValidValueMultiton::memberByValueWithDefault('rab')); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberByValueWithDefault('Oof', null, false)); $this->assertSame( ValidValueMultiton::FOO(), ValidValueMultiton::memberByValueWithDefault('qux', ValidValueMultiton::FOO()) @@ -328,6 +333,20 @@ public function testMemberByValueWithDefault() $this->assertNull(ValidValueMultiton::memberByValueWithDefault('qux')); } + public function testMemberOrNullByValue() + { + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullByValue('oof')); + $this->assertSame(ValidValueMultiton::BAR(), ValidValueMultiton::memberOrNullByValue('rab')); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullByValue('Oof', false)); + $this->assertNull(ValidValueMultiton::memberOrNullByValue(null)); + } + + public function testMemberOrNullByValueFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidValueMultiton::memberOrNullByValue('mood'); + } + public function testMembersByValue() { $this->assertSame(array('FOO' => ValidValueMultiton::FOO()), ValidValueMultiton::membersByValue('oof')); From bd6ce7a9ca4fe62cf729f03a3fc5b7ab07952f3b Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 14 Feb 2014 17:29:50 +1000 Subject: [PATCH 2/6] Implemented memberOrNullByKey. Relates to #18. --- src/AbstractMultiton.php | 17 +++++++++++++++++ src/AbstractValueMultiton.php | 3 ++- test/suite/AbstractMultitonTest.php | 14 ++++++++++++++ test/suite/AbstractValueMultitonTest.php | 14 ++++++++++++++ 4 files changed, 47 insertions(+), 1 deletion(-) diff --git a/src/AbstractMultiton.php b/src/AbstractMultiton.php index 3c6c4c9..8a9b616 100644 --- a/src/AbstractMultiton.php +++ b/src/AbstractMultiton.php @@ -56,6 +56,23 @@ final public static function memberByKeyWithDefault( ); } + /** + * Returns a single member by string key. Additionally returns null if the + * supplied key is null. + * + * @param string|null $key The string key associated with the member, or null. + * @param boolean|null $isCaseSensitive True if the search should be case sensitive. + * + * @return MultitonInterface|null The member associated with the given string key, or null if the supplied key is null. + * @throws Exception\UndefinedMemberExceptionInterface If no associated member is found. + */ + final public static function memberOrNullByKey( + $key, + $isCaseSensitive = null + ) { + return static::memberOrNullBy('key', $key, $isCaseSensitive); + } + /** * Returns a single member by comparison with the result of an accessor * method. diff --git a/src/AbstractValueMultiton.php b/src/AbstractValueMultiton.php index 7404456..d685ca7 100644 --- a/src/AbstractValueMultiton.php +++ b/src/AbstractValueMultiton.php @@ -55,7 +55,8 @@ final public static function memberByValueWithDefault( } /** - * Returns a single member by value. + * Returns a single member by value. Additionally returns null if the + * supplied value is null. * * @param scalar|null $value The value associated with the member, or null. * @param boolean|null $isCaseSensitive True if the search should be case sensitive. diff --git a/test/suite/AbstractMultitonTest.php b/test/suite/AbstractMultitonTest.php index 7461f3a..eca13b7 100644 --- a/test/suite/AbstractMultitonTest.php +++ b/test/suite/AbstractMultitonTest.php @@ -69,6 +69,20 @@ public function testMemberByKeyWithDefault() $this->assertNull(ValidMultiton::memberByKeyWithDefault('qux')); } + public function testMemberOrNullByKey() + { + $this->assertSame(ValidMultiton::FOO(), ValidMultiton::memberOrNullByKey('FOO')); + $this->assertSame(ValidMultiton::BAR(), ValidMultiton::memberOrNullByKey('BAR')); + $this->assertSame(ValidMultiton::FOO(), ValidMultiton::memberOrNullByKey('Foo', false)); + $this->assertNull(ValidMultiton::memberOrNullByKey(null)); + } + + public function testMemberOrNullByKeyFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidMultiton::memberOrNullByKey('DOOM'); + } + public function testMemberBy() { $this->assertSame(array(), ValidMultiton::calls()); diff --git a/test/suite/AbstractValueMultitonTest.php b/test/suite/AbstractValueMultitonTest.php index 10645b2..f75b2a4 100644 --- a/test/suite/AbstractValueMultitonTest.php +++ b/test/suite/AbstractValueMultitonTest.php @@ -69,6 +69,20 @@ public function testMemberByKeyWithDefault() $this->assertNull(ValidValueMultiton::memberByKeyWithDefault('qux')); } + public function testMemberOrNullByKey() + { + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullByKey('FOO')); + $this->assertSame(ValidValueMultiton::BAR(), ValidValueMultiton::memberOrNullByKey('BAR')); + $this->assertSame(ValidValueMultiton::FOO(), ValidValueMultiton::memberOrNullByKey('Foo', false)); + $this->assertNull(ValidValueMultiton::memberOrNullByKey(null)); + } + + public function testMemberOrNullByKeyFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidValueMultiton::memberOrNullByKey('DOOM'); + } + public function testMemberBy() { $this->assertSame(array(), ValidValueMultiton::calls()); From 2b8c7085a82a9a9bb008449cae1b9e9e126ec5a8 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 14 Feb 2014 17:31:09 +1000 Subject: [PATCH 3/6] Forgot to save. Relates to #18. --- test/suite/AbstractEnumerationTest.php | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/test/suite/AbstractEnumerationTest.php b/test/suite/AbstractEnumerationTest.php index b71f116..1f30879 100644 --- a/test/suite/AbstractEnumerationTest.php +++ b/test/suite/AbstractEnumerationTest.php @@ -61,6 +61,20 @@ public function testMemberByKeyWithDefault() $this->assertNull(ValidEnumeration::memberByKeyWithDefault('qux')); } + public function testMemberOrNullByKey() + { + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullByKey('FOO')); + $this->assertSame(ValidEnumeration::BAR(), ValidEnumeration::memberOrNullByKey('BAR')); + $this->assertSame(ValidEnumeration::FOO(), ValidEnumeration::memberOrNullByKey('Foo', false)); + $this->assertNull(ValidEnumeration::memberOrNullByKey(null)); + } + + public function testMemberOrNullByKeyFailureUndefined() + { + $this->setExpectedException('Eloquent\Enumeration\Exception\UndefinedMemberException'); + ValidEnumeration::memberOrNullByKey('DOOM'); + } + public function testMemberBy() { $foo = ValidEnumeration::memberBy('key', 'FOO'); From 9e266d25024f77433624e3c4b24c8346810e9bfd Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Fri, 14 Feb 2014 17:34:16 +1000 Subject: [PATCH 4/6] Updated Archer config. --- .travis.install | 21 ++++++++++++++------- .travis.yml | 11 ++--------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/.travis.install b/.travis.install index 63eb428..47961e7 100755 --- a/.travis.install +++ b/.travis.install @@ -1,10 +1,14 @@ #!/usr/bin/env php array( 'notify-on-install' => false @@ -16,20 +20,23 @@ if ($token = getenv('ARCHER_TOKEN')) { 'github.com' => $token ); $composerFlags = '--prefer-dist'; - passthru('curl -s -i -H "Authorization: token $ARCHER_TOKEN" https://api.github.com | grep "^X-RateLimit"'); } else { $composerFlags = '--prefer-source'; } $file = '~/.composer/config.json'; -$dir = dirname($file); +$dir = dirname($file); if (!is_dir($dir)) { mkdir($dir, 0755, true); } file_put_contents($file, json_encode($config)); -passthru('composer self-update --no-interaction'); +// Display some information about GitHub rate limiting ... +if ($token) { + passthru('curl -s -i -H "Authorization: token $ARCHER_TOKEN" https://api.github.com | grep "^X-RateLimit"'); +} +// Install composer dependencies ... $exitCode = 0; passthru('composer install --dev --no-progress --no-interaction --ansi ' . $composerFlags, $exitCode); exit($exitCode); diff --git a/.travis.yml b/.travis.yml index 4428537..b127fff 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,11 +1,3 @@ -# -# This is the default Travis CI configuration. -# -# It uses a GitHub OAuth token when fetching composer dependencies -# to avoid IP-based API throttling. -# -# It also allows publication of artifacts via an additional build. -# language: php php: ["5.3", "5.4", "5.5", "hhvm"] @@ -16,10 +8,11 @@ matrix: env: global: - - ARCHER_PUBLISH_VERSION=5.4 + - ARCHER_PUBLISH_VERSION=5.5 - secure: "RshLtPfJvPQyIxEsUXlBc/DEfv2uEBvr2gf4Ml6qIbnCjeGUknyhGpjm/oLn4gL0lonTC3gLhT3PVkZG8yTCjFrThnLPucty9LFT4hLfqH2JTSrqYWc57sS3EuaAbjYUo/UtKV9QQTBm3TQYuWGKamzTnNtNM6lITrL19zfcAbM=" install: - ./.travis.install + script: - ./vendor/bin/archer travis:build From 49ead758b6a8e34e9f6cd75795659ec2ceac29b9 Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Thu, 13 Mar 2014 11:12:05 +1000 Subject: [PATCH 5/6] Updated dependencies. --- composer.lock | 148 +++++++++++++++++++++++++++++--------------------- 1 file changed, 86 insertions(+), 62 deletions(-) diff --git a/composer.lock b/composer.lock index 9682c60..6ced89f 100644 --- a/composer.lock +++ b/composer.lock @@ -161,16 +161,16 @@ }, { "name": "icecave/archer", - "version": "1.1.2", + "version": "1.1.4", "source": { "type": "git", "url": "https://github.com/IcecaveStudios/archer.git", - "reference": "c8f777640f216f75d10905619135d4f92bb0223f" + "reference": "dfc39396bdd9bc22ba00beecc3cfc26fcb535197" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/IcecaveStudios/archer/zipball/c8f777640f216f75d10905619135d4f92bb0223f", - "reference": "c8f777640f216f75d10905619135d4f92bb0223f", + "url": "https://api.github.com/repos/IcecaveStudios/archer/zipball/dfc39396bdd9bc22ba00beecc3cfc26fcb535197", + "reference": "dfc39396bdd9bc22ba00beecc3cfc26fcb535197", "shasum": "" }, "require": { @@ -194,8 +194,8 @@ ], "type": "library", "autoload": { - "psr-0": { - "Icecave\\Archer": "src" + "psr-4": { + "Icecave\\Archer\\": "src" } }, "notification-url": "https://packagist.org/downloads/", @@ -229,7 +229,7 @@ "testing", "unit" ], - "time": "2014-01-21 01:56:19" + "time": "2014-02-18 03:03:13" }, { "name": "nikic/php-parser", @@ -530,17 +530,17 @@ }, { "name": "symfony/config", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Config", "source": { "type": "git", "url": "https://github.com/symfony/Config.git", - "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a" + "reference": "d81bd01eac1514c10dcb3b11eaa9048d6b87dd1f" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Config/zipball/27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", - "reference": "27d0b35879ebefcfee6d218512c32ab2d6cd6a6a", + "url": "https://api.github.com/repos/symfony/Config/zipball/d81bd01eac1514c10dcb3b11eaa9048d6b87dd1f", + "reference": "d81bd01eac1514c10dcb3b11eaa9048d6b87dd1f", "shasum": "" }, "require": { @@ -565,7 +565,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -574,21 +576,21 @@ ], "description": "Symfony Config Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/console", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Console", "source": { "type": "git", "url": "https://github.com/symfony/Console.git", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7" + "reference": "940f217cbc3c8a33e5403e7c595495c4884400fe" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Console/zipball/4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", - "reference": "4c1ed2ff514bd85ee186eebb010ccbdeeab05af7", + "url": "https://api.github.com/repos/symfony/Console/zipball/940f217cbc3c8a33e5403e7c595495c4884400fe", + "reference": "940f217cbc3c8a33e5403e7c595495c4884400fe", "shasum": "" }, "require": { @@ -618,7 +620,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -627,21 +631,21 @@ ], "description": "Symfony Console Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/event-dispatcher", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/EventDispatcher", "source": { "type": "git", "url": "https://github.com/symfony/EventDispatcher.git", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601" + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/e3ba42f6a70554ed05749e61b829550f6ac33601", - "reference": "e3ba42f6a70554ed05749e61b829550f6ac33601", + "url": "https://api.github.com/repos/symfony/EventDispatcher/zipball/4708b8cd41984a5ba29fe7dd40716f7f761ac501", + "reference": "4708b8cd41984a5ba29fe7dd40716f7f761ac501", "shasum": "" }, "require": { @@ -672,7 +676,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -681,21 +687,21 @@ ], "description": "Symfony EventDispatcher Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/filesystem", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Filesystem", "source": { "type": "git", "url": "https://github.com/symfony/Filesystem.git", - "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78" + "reference": "7e65abb06d3b38f4be89266fe3fb4a759544e713" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Filesystem/zipball/b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", - "reference": "b3c3b5a8108b3e5d604dc23241b4ea84a067fc78", + "url": "https://api.github.com/repos/symfony/Filesystem/zipball/7e65abb06d3b38f4be89266fe3fb4a759544e713", + "reference": "7e65abb06d3b38f4be89266fe3fb4a759544e713", "shasum": "" }, "require": { @@ -719,7 +725,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -728,21 +736,21 @@ ], "description": "Symfony Filesystem Component", "homepage": "http://symfony.com", - "time": "2013-12-31 13:43:26" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/finder", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Finder", "source": { "type": "git", "url": "https://github.com/symfony/Finder.git", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a" + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Finder/zipball/6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", - "reference": "6904345cf2b3bbab1f6d6e4ce1724cb99df9f00a", + "url": "https://api.github.com/repos/symfony/Finder/zipball/b6735d1fc16da13c4c7dddfe78366a4a098cf011", + "reference": "b6735d1fc16da13c4c7dddfe78366a4a098cf011", "shasum": "" }, "require": { @@ -766,7 +774,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -775,21 +785,21 @@ ], "description": "Symfony Finder Component", "homepage": "http://symfony.com", - "time": "2014-01-01 08:14:50" + "time": "2014-01-07 13:28:54" }, { "name": "symfony/process", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Process", "source": { "type": "git", "url": "https://github.com/symfony/Process.git", - "reference": "58fdccb311e44f28866f976c2d7b3227e9f713db" + "reference": "c175448bac997556f8ab972908a4e14c7291fb03" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Process/zipball/58fdccb311e44f28866f976c2d7b3227e9f713db", - "reference": "58fdccb311e44f28866f976c2d7b3227e9f713db", + "url": "https://api.github.com/repos/symfony/Process/zipball/c175448bac997556f8ab972908a4e14c7291fb03", + "reference": "c175448bac997556f8ab972908a4e14c7291fb03", "shasum": "" }, "require": { @@ -813,7 +823,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -822,21 +834,21 @@ ], "description": "Symfony Process Component", "homepage": "http://symfony.com", - "time": "2014-01-05 02:10:50" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/stopwatch", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Stopwatch", "source": { "type": "git", "url": "https://github.com/symfony/Stopwatch.git", - "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5" + "reference": "bffad325e36a3e71fba6d5dcce6e2f4b4637b91a" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/c8e21e1380c7eef6197a8165620da8457b7c69a5", - "reference": "c8e21e1380c7eef6197a8165620da8457b7c69a5", + "url": "https://api.github.com/repos/symfony/Stopwatch/zipball/bffad325e36a3e71fba6d5dcce6e2f4b4637b91a", + "reference": "bffad325e36a3e71fba6d5dcce6e2f4b4637b91a", "shasum": "" }, "require": { @@ -860,7 +872,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -869,21 +883,21 @@ ], "description": "Symfony Stopwatch Component", "homepage": "http://symfony.com", - "time": "2013-12-12 16:06:47" + "time": "2014-02-11 13:52:09" }, { "name": "symfony/yaml", - "version": "v2.4.1", + "version": "v2.4.2", "target-dir": "Symfony/Component/Yaml", "source": { "type": "git", "url": "https://github.com/symfony/Yaml.git", - "reference": "4e1a237fc48145fae114b96458d799746ad89aa0" + "reference": "bb6ddaf8956139d1b8c360b4b713ed0138e876b3" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/symfony/Yaml/zipball/4e1a237fc48145fae114b96458d799746ad89aa0", - "reference": "4e1a237fc48145fae114b96458d799746ad89aa0", + "url": "https://api.github.com/repos/symfony/Yaml/zipball/bb6ddaf8956139d1b8c360b4b713ed0138e876b3", + "reference": "bb6ddaf8956139d1b8c360b4b713ed0138e876b3", "shasum": "" }, "require": { @@ -907,7 +921,9 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Symfony Community", @@ -916,20 +932,20 @@ ], "description": "Symfony Yaml Component", "homepage": "http://symfony.com", - "time": "2013-12-28 08:12:03" + "time": "2014-01-07 13:28:54" }, { "name": "twig/twig", - "version": "v1.15.0", + "version": "v1.15.1", "source": { "type": "git", "url": "https://github.com/fabpot/Twig.git", - "reference": "85e4ff98000157ff753d934b9f13659a953f5666" + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/fabpot/Twig/zipball/85e4ff98000157ff753d934b9f13659a953f5666", - "reference": "85e4ff98000157ff753d934b9f13659a953f5666", + "url": "https://api.github.com/repos/fabpot/Twig/zipball/1fb5784662f438d7d96a541e305e28b812e2eeed", + "reference": "1fb5784662f438d7d96a541e305e28b812e2eeed", "shasum": "" }, "require": { @@ -953,11 +969,19 @@ "authors": [ { "name": "Fabien Potencier", - "email": "fabien@symfony.com" + "email": "fabien@symfony.com", + "homepage": "http://fabien.potencier.org", + "role": "Lead Developer" }, { "name": "Armin Ronacher", - "email": "armin.ronacher@active-4.com" + "email": "armin.ronacher@active-4.com", + "role": "Project Founder" + }, + { + "name": "Twig Team", + "homepage": "https://github.com/fabpot/Twig/graphs/contributors", + "role": "Contributors" } ], "description": "Twig, the flexible, fast, and secure template language for PHP", @@ -965,7 +989,7 @@ "keywords": [ "templating" ], - "time": "2013-12-06 07:47:10" + "time": "2014-02-13 10:19:29" } ], "aliases": [ From abcc9e40215144216a6758d118c2e232e7972e2c Mon Sep 17 00:00:00 2001 From: Erin Millard Date: Thu, 13 Mar 2014 11:16:50 +1000 Subject: [PATCH 6/6] Updated readme, changelog, contributing info. --- CHANGELOG.md | 4 ++++ CONTRIBUTING.md | 25 ++++++++++++++----------- README.md | 4 ++-- 3 files changed, 20 insertions(+), 13 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 555db6b..c64ca15 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,9 @@ # Enumeration changelog +## 5.1.0 (2014-03-13) + +- **[NEW]** Implemented `memberOrNullBy()` and variants + ## 5.0.1 (2014-01-29) - **[MAINTENANCE]** General repository maintenance diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index e2c35d3..583471a 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -6,24 +6,27 @@ changes. ### Code style -All PHP code must adhere to the -[PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) -standards. +All PHP code must adhere to the [PSR-2] standards. ### Branching and pull requests As a guideline, please follow this process: - 1. [Fork the repository](https://help.github.com/articles/fork-a-repo). + 1. [Fork the repository]. 2. Create a topic branch for the change: - * New features should branch from **develop**. - * Bug fixes to existing versions should branch from **master**. - * Please ensure the branch is clearly labelled as a feature or fix. + - New features should branch from **develop**. + - Bug fixes to existing versions should branch from **master**. + - Please ensure the branch is clearly labelled as a feature or fix. 3. Make the relevant changes. - 4. [Squash](http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages) - commits if necessary. + 4. [Squash] commits if necessary. 4. Submit a pull request to the **develop** branch. Please note this is a general guideline only. For more information on the -branching structure please see the -[git-flow cheatsheet](http://danielkummer.github.com/git-flow-cheatsheet/). +branching structure please see the [git-flow cheatsheet]. + + + +[Fork the repository]: https://help.github.com/articles/fork-a-repo +[git-flow cheatsheet]: http://danielkummer.github.com/git-flow-cheatsheet/ +[PSR-2]: https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md +[Squash]: http://git-scm.com/book/en/Git-Tools-Rewriting-History#Changing-Multiple-Commit-Messages diff --git a/README.md b/README.md index f592427..43af26b 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ *An enumeration implementation for PHP.* -[![The most recent stable version is 5.0.1][version-image]][Semantic versioning] +[![The most recent stable version is 5.1.0][version-image]][Semantic versioning] [![Current build status image][build-image]][Current build status] [![Current coverage status image][coverage-image]][Current coverage status] @@ -274,4 +274,4 @@ function handleCustomHttpRequest( [Current coverage status]: https://coveralls.io/r/eloquent/enumeration [eloquent/enumeration]: https://packagist.org/packages/eloquent/enumeration [Semantic versioning]: http://semver.org/ -[version-image]: http://img.shields.io/:semver-5.0.1-brightgreen.svg "This project uses semantic versioning" +[version-image]: http://img.shields.io/:semver-5.1.0-brightgreen.svg "This project uses semantic versioning"