https://github.com/treblle/funxtion-php
The SDK from Treblle Hacktoberfest 2023 for the Funxtion API
https://github.com/treblle/funxtion-php
Last synced: about 1 year ago
JSON representation
The SDK from Treblle Hacktoberfest 2023 for the Funxtion API
- Host: GitHub
- URL: https://github.com/treblle/funxtion-php
- Owner: Treblle
- Created: 2023-10-13T11:37:29.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2023-10-13T12:16:09.000Z (over 2 years ago)
- Last Synced: 2025-01-24T12:45:46.213Z (over 1 year ago)
- Language: PHP
- Size: 47.9 KB
- Stars: 2
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Funxtion PHP SDK
## Usage
```php
$funxtion = new \Funxtion\Funxtion(
token: '123123123',
url: '123123123',
);
// Get a list of exercises
$funxtion->exercises()->list(
new \Funxtion\Filters\WhereFilter(
key: 'name',
value: 'Steve',
operator: \Funxtion\Enums\Operator::CONTAINS,
),
new \Funxtion\Filters\WhereFilter(
key: 'equipment',
value: '1,2',
operator: \Funxtion\Enums\Operator::IN,
),
);
```
## Example Implementation
```php
use Funxtion\Funxtion;
use Funxtion\ValueObjects\ExerciseCollectionItem;
class FunxtionService
{
public function __construct(
private readonly Funxtion $funxtion,
) {}
public function listExercise()
{
$response = $this->funxtion->exercises()->list();
return array_map(
callback: fn (array $item) => ExerciseCollectionItem::fromArray(
data: $item,
),
array: json_decode(
json: $response->getBody()->getContents(),
associative: true,
flags: JSON_THROW_ON_ERROR,
)['data'],
);
}
}
```