Skip to content
This repository was archived by the owner on Jan 2, 2023. It is now read-only.
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
3d61e47
New resource-based API
tobyzerner Mar 9, 2017
6494584
Merge branch 'master' into resource-interface
tobyzerner Mar 9, 2017
f395b01
Apply fixes from StyleCI
tobyzerner Mar 9, 2017
1795c83
Merge pull request #120 from tobscure/analysis-qJbw7o
tobyzerner Mar 9, 2017
ba8a379
Only pull a resource out of the map if it exists
tobyzerner Mar 26, 2017
d25a3f4
Remove some methods from public API
tobyzerner Mar 26, 2017
4e80ea8
Decode pagination link query string (no reason for it to be encoded)
tobyzerner Mar 26, 2017
5430fba
Update ResourceInterface docblocks
tobyzerner Mar 26, 2017
2ab0ac2
Rewrite tests
tobyzerner Mar 26, 2017
946cc45
Apply fixes from StyleCI
tobyzerner Mar 26, 2017
820e516
Merge pull request #122 from tobscure/analysis-XNwgj1
tobyzerner Mar 26, 2017
6f9cf92
Drop support for PHPUnit 5.0 for now
tobyzerner Mar 26, 2017
24f092d
Update README
tobyzerner Mar 27, 2017
a350d25
Add some missing docs
tobyzerner Mar 27, 2017
0d66e3b
Formatting
tobyzerner Mar 27, 2017
ea20221
Add sparse fieldsets to example
tobyzerner Mar 27, 2017
2a3c32a
Tweak wording
tobyzerner Mar 27, 2017
cb7702e
More tweaks
tobyzerner Mar 27, 2017
c7b8a32
Revert "Decode pagination link query string (no reason for it to be e…
tobyzerner Mar 27, 2017
880a28d
Reverse non-encoding of pagination URLs (should've read the spec more…
tobyzerner Mar 27, 2017
ac96c04
Support page[size] in pagination links
tobyzerner Mar 27, 2017
a071a76
Improve README; add references to JSON-API spec
tobyzerner Mar 27, 2017
44ed154
New error handling API in README (not implemented yet)
tobyzerner Mar 27, 2017
4ad47d1
README: Make link methods more explicit, add Link objects (not implem…
tobyzerner Mar 27, 2017
3321513
README: Simplify new error handling API: less magic, less surface area
tobyzerner Mar 27, 2017
27a25b5
Formatting
tobyzerner Mar 27, 2017
afa7d3f
Formatting
tobyzerner Mar 27, 2017
2f15ded
Formatting
tobyzerner Mar 27, 2017
8c2a260
Tweaks
tobyzerner Mar 27, 2017
b9923e3
Add default error response for ease
tobyzerner Mar 27, 2017
ffa2bf8
Big changes
tobyzerner Mar 28, 2017
9cf8336
Apply fixes from StyleCI
tobyzerner Mar 28, 2017
ed3d163
Merge pull request #123 from tobscure/analysis-qJ4m9Q
tobyzerner Mar 28, 2017
d1a008f
Relationship static constructors
tobyzerner Mar 28, 2017
a39459d
Apply fixes from StyleCI
tobyzerner Mar 28, 2017
1c93c27
Merge pull request #124 from tobscure/analysis-XaLlmW
tobyzerner Mar 28, 2017
d50ba8a
More big changes, hopefully the last lot
tobyzerner Mar 29, 2017
e940b9f
Apply fixes from StyleCI
tobyzerner Mar 29, 2017
6878c9c
Merge pull request #125 from tobscure/analysis-Xl91rQ
tobyzerner Mar 29, 2017
6bf5873
Fix failing test
tobyzerner Mar 29, 2017
de73055
Fix Relationship constructors
tobyzerner Mar 30, 2017
10adcf3
DRY-ed up tests
f3ath Sep 14, 2017
47e8d6d
Merge pull request #134 from f3ath/dry-up-tests
tobyzerner Sep 14, 2017
50ffec7
Added a benchmark
f3ath Mar 3, 2018
a0ddfe4
Merge pull request #141 from f3ath/benchmarks
tobyzerner Mar 3, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 10 additions & 31 deletions src/AbstractSerializer.php → src/AbstractResource.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,13 @@

use LogicException;

abstract class AbstractSerializer implements SerializerInterface
abstract class AbstractResource implements ResourceInterface
{
use LinksTrait;
use MetaTrait;

/**
* The type.
* The resource type.
*
* @var string
*/
Expand All @@ -25,39 +28,15 @@ abstract class AbstractSerializer implements SerializerInterface
/**
* {@inheritdoc}
*/
public function getType($model)
public function getType()
{
return $this->type;
}

/**
* {@inheritdoc}
*/
public function getId($model)
{
return $model->id;
}

/**
* {@inheritdoc}
*/
public function getAttributes($model, array $fields = null)
{
return [];
}

/**
* {@inheritdoc}
*/
public function getLinks($model)
{
return [];
}

/**
* {@inheritdoc}
*/
public function getMeta($model)
public function getAttributes(array $fields = null)
{
return [];
}
Expand All @@ -67,12 +46,12 @@ public function getMeta($model)
*
* @throws \LogicException
*/
public function getRelationship($model, $name)
public function getRelationship($name)
{
$method = $this->getRelationshipMethodName($name);

if (method_exists($this, $method)) {
$relationship = $this->$method($model);
$relationship = $this->$method();

if ($relationship !== null && ! ($relationship instanceof Relationship)) {
throw new LogicException('Relationship method must return null or an instance of Tobscure\JsonApi\Relationship');
Expand All @@ -83,7 +62,7 @@ public function getRelationship($model, $name)
}

/**
* Get the serializer method name for the given relationship.
* Get the method name for the given relationship.
*
* snake_case and kebab-case are converted into camelCase.
*
Expand Down
126 changes: 0 additions & 126 deletions src/Collection.php

This file was deleted.

Loading