Skip to content
This repository was archived by the owner on Aug 25, 2018. It is now read-only.

Refactoring and modernization #18

Merged
merged 13 commits into from
Jun 16, 2015
Merged

Refactoring and modernization #18

merged 13 commits into from
Jun 16, 2015

Conversation

jeromegamez
Copy link
Contributor

Following #17, my wish to just modernize the Generator went a little out of control 😊, so here it is.

Notable changes:

  • The minimum PHP requirement is now PHP 5.4, the generator currently works up to PHP 7 and HHVM.
  • The base namespace is Firebase\Token
  • Services_FirebaseTokenGenerator is now Firebase\Token\TokenGenerator and the usage has been changed (see the updated README for examples)
  • Exceptions are wrapped into the TokenException which makes it easier to catch them in the projects in which the generator is used
  • A .editorconfig and .php_cs (see PHP Coding Standards Fixer) file are now present. The settings in here are of course highly opinionated :)
  • A config for Travis-CI has been added, you can see the current build results here: https://travis-ci.org/jeromegamez/firebase-token-generator-php
  • A changelog has been added (I like to use @mtdowling's chag very much)

I removed some checks from the tests, even the one I introduced myself 😄, because I became aware that these checks should be (and are already) done in the JWT library, not in this token generator.

And finally, here are the test results and code coverage reports:

Firebase\Token\Tests\FirebaseToken
 [x] Create
 [x] Admin debug
 [x] Malformed key throws exception
 [x] Expires
 [x] Not before object
 [x] No u i d
 [x] Invalid u i d
 [x] U i d too long
 [x] U i d min length
 [x] Token too long
 [x] No u i d with admin
 [x] Invalid u i d with admin 1
 [x] Invalid u i d with admin 2
 [x] Invalid u i d with admin 3
 [x] Empty data and no options throws exception
 [x] Malformed data throws exception
 [x] Object is treated as array

Firebase\Token\Tests\TokenGenerator
 [x] Default options
 [x] Set options
 [x] Trigger exception on unsupported option
 [x] Trigger exception on invalid option
 [x] Trigger exception on invalid secret
 [x] Trigger exception on missing uid
 [x] Trigger exception on non string uid
 [x] Trigger exception if uid is too long
 [x] Trigger exception if uid is empty
 [x] Trigger exception if generated token is too long
 [x] Allow empty uid if admin option is set
 [x] Trigger exception on jwt exception



Code Coverage Report:
  2015-06-11 21:01:52

 Summary:
  Classes: 100.00% (3/3)
  Methods: 100.00% (10/10)
  Lines:   100.00% (108/108)

@Services::Services_FirebaseTokenGenerator
  Methods: 100.00% ( 2/ 2)   Lines: 100.00% ( 15/ 15)
\Firebase\Token::TokenGenerator
  Methods: 100.00% ( 8/ 8)   Lines: 100.00% ( 93/ 93)

Your feedback is highly appreciated, and I will happily apply change requests to make this work. I am aware that this is a quite radical change, but people using the current version should not be affected and can continue using a version < 3.0

Cheers!
:octocat: Jérôme

@robertdimarco robertdimarco self-assigned this May 30, 2015
@robertdimarco
Copy link
Contributor

@jeromegamez Sorry for the delay on this! Promise I'll have a review for you within the next 24 hours.

@robertdimarco
Copy link
Contributor

@jeromegamez Wow, this is great. A big thumbs-up from me.

One point of feedback: with the change of the method signatures, this introduces a breaking change for every consumer of the library, and a major version bump. What are your thoughts on adding the original method signature back into the library for backwards compatibility, and it can just call into the new one? We can make the new way the latest-and-greatest, while making the upgrade path seamless.

@jeromegamez
Copy link
Contributor Author

Thank you so much for the positive feedback!

Re-adding the original method signature is certainly feasible, I will get to it as soon as I can and add it to this PR.

@jeromegamez
Copy link
Contributor Author

Uh, there's one thing - the minimum PHP requirement would then impose a problem: PHP 5.2 doesn't support namespaces, so this is a breaking change that would require a major version bump anyways - unless I am overseeing something :/.

Without it, an existing PHP 5.2 project would receive the new version through a composer update and get errors because of the namespaces.

@jeromegamez
Copy link
Contributor Author

@robertdimarco Your suggestion to re-introduce the legacy generator allowed me to fix some errors that slipped in during the refactoring (especially the wrong ait typo), whew!

I also re-introduced the old test suite, just to make sure that really everything works as expected.

You can see the latest Travis CI test results here: https://travis-ci.org/jeromegamez/firebase-token-generator-php/builds/66446660

@robertdimarco
Copy link
Contributor

@jeromegamez Perfection, I think that is the right approach, and I'm glad to see that the legacy test suite was reintroduced (and that proved to be useful!). I'll take a look at this later today and see if we can merge + cut a release.

@robertdimarco
Copy link
Contributor

Again @jeromegamez huge thanks to you and thanks for your patience

robertdimarco added a commit that referenced this pull request Jun 16, 2015
@robertdimarco robertdimarco merged commit e1a431b into googlearchive:master Jun 16, 2015
@jeromegamez jeromegamez deleted the feature/modernization branch June 16, 2015 18:15
@jeromegamez
Copy link
Contributor Author

No, thank you - I couldn't be happier right now! ❤️

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants