facebook/facebook-php-sdk-v4 — pull request #175 by yguedidi (2014-07-29 00:42:19+00:00)
Title: [4.1] Refactor

Hello @gfosco, @SammyK!
I had some time this past weekend, so I continue my work on my personal point of view about the refactor. (I also learn how to make better tests lol)
Even if it's not yet finished and not yet perfect, it will show you main features. I think the code is lighter and easier to understand.
The diff may be difficult to read, so it's better to review this commit by commit ;)
# Internals
### Usage
```php
$facebookApp = new FacebookApp($appId, $appSecret);
$facebookClient = new FacebookClient(/*$httpClient, $useSecretProof, $useBeta*/)

// Get an access token through a helper or:
$accessToken = new AccessToken($facebookApp, $accessTokenValue);

$request = new FacebookRequest($endpoint/*, $method, $params, $accessToken, $graphVersion, $eTag*/);
$requests = [
$request,
new FacebookBatchedRequest($request/*, $name, $dependsOn, $omitResponseOnSuccess*/)
];
$batchRequest = new FacebookBatchRequest($requests/*, $fallbackAccessToken*/);

$response = $facebookClient->handle($request);
$batchResponse = $facebookClient->handle($batchRequest);
```
### AccessToken
```php
$secretProof = $accessToken->getSecretProof(); // a value, no needs for an entity
$code = $accessToken->getCode($facebookClient/*, $redirectUri */);
$extended = $accessToken->getExtended($facebookClient);
$debugged = $accessToken->getDebugged($facebookClient);
$debugged->getAppId(); $debugged->getScope(); // ...
```
### Code
```php
$code = new Code($facebookApp, $codeValue);
$accessToken = $code->getAccessToken($facebookClient, $redirectUri/*, $machineId */);
```
### SignedRequest
```php
$signedRequest = new SignedRequest($facebookApp, $signedRequestValue/*, $state */);
$signedRequest->getAccessToken($facebookClient);
```

All above object are __value object__, they are immutable, without any setter, they don't change once they are created.
# Tests
### Refactor
I remove all graph calls from tests. They seems more test the Graph API structure than the SDK reaction to Graph API response.
So I change all tests to unit test with fake data. Test suite is now faster!
### Functionnal testing
It can be useful for end user to have a way to use functional test in his app. Thats why I add a ``FacebookTestHelper`` that manage the test user using a PHPUnit test listener and a ``FacebookTestCase`` with helper functions.
# End-user API
Don't take builders in account now, we'll should discut about them later.