Skip to content
This repository has been archived by the owner on May 1, 2019. It is now read-only.

[WIP] Enhancement: Added GitHub Repository Service #287

Merged
merged 26 commits into from
Jan 11, 2015

Conversation

ins0
Copy link
Contributor

@ins0 ins0 commented Dec 16, 2014

Added GithubService and moved controller methods to service


use EdpGithub\Client;

class GithubService
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Naming is a bit generic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

any suggestitions? i'm not very smart in naming classes :)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's its purpose, in words?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GithubRepositoryService ?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ins0 no, I'm asking for a plain-english description of what this object represents, without programmer terminology

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

RepositoryRetriever - GithubRepositoryRetriever without the prefix Github i think this can be misunderstood with the Db Repository Mapper

@Ocramius
Copy link
Member

Overall a good refactoring, but some things still missing:

  • tests for the newly introduced logic (and you'll see how much demeter is broken here due to all the internal chained methods)
  • return types should be much more specific, and I suggest encapsulating the retrieved data into small value objects that validate data format at __construct time and have public getters just for what we need

@ins0
Copy link
Contributor Author

ins0 commented Dec 16, 2014

thanks for your review @Ocramius

@ins0 ins0 changed the title Enhancement: Added GitHub Repository Service [WIP] Enhancement: Added GitHub Repository Service Dec 16, 2014
@ins0
Copy link
Contributor Author

ins0 commented Dec 16, 2014

@Ocramius what is your opinion - should this service moved to a seperate module folder if this code and classes grows?

@Ocramius
Copy link
Member

@ins0 it's fine as-is if the service is Application-specific.

{
$repositoryCollection = $this->githubClient->api('current_user')->repos($params);
if( $repositoryCollection instanceof RepositoryCollection )
{
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ins0

If you run

$ vendor/bin/phpcbf --standard=./phpcs.xml .

your CS issues will be resolved. See https://travis-ci.org/zendframework/modules.zendframework.com/jobs/44193562#L264.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i know, didn't set up a hook for cs fix on commit and travel between locations (no laptop) i was forced to push :)

@@ -87,6 +87,7 @@
'service_manager' => array(
'factories' => array(
'translator' => 'Zend\I18n\Translator\TranslatorServiceFactory',
'RepositoryRetriever' => 'Application\Service\RepositoryRetrieverFactory',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we moved to 5.5, please use ::class syntax

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also don't call it just RepositoryRetriever, but use the FQCN via RepositoryRetriever::class

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@Ocramius

Not sure if we've got PHP5.5 already, do we? If so, 👍.

$service = $this->prepareService(new Api\CurrentUser, json_encode($payload));

$repositories = $service->getAuthenticatedUserRepositories();
$this->assertInstanceOf('EdpGithub\Collection\RepositoryCollection', $repositories);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can leverage the class keyword here, too. Helps a lot with finding usages in PhpStorm, too.

@localheinz localheinz self-assigned this Jan 10, 2015
@@ -3,7 +3,6 @@ language: php
sudo: false

php:
- 5.4
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ins0

The only clue I currently have about what PHP version is currently running on the production machine is #284 (comment), so I think it's not really safe yet to assume we can rely on the availability of PHP5.5.

Can you make the changes in this PR PHP5.4 compliant?

  • class keyword
  • generators?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

👍

localheinz added a commit to localheinz/modules.zendframework.com that referenced this pull request Jan 11, 2015
@localheinz localheinz merged commit 9964ba1 into zendframework:master Jan 11, 2015
@localheinz
Copy link
Member

Merged after discussing with @ins0 on Skype.

Thanks a lot, @ins0!

@ins0 ins0 deleted the fix/github-service branch January 11, 2015 17:40
@ins0 ins0 restored the fix/github-service branch January 16, 2015 07:33
@ins0 ins0 deleted the fix/github-service branch February 7, 2015 19:25
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.

3 participants