Skip to content

Commit

Permalink
PSR1/PSR2 formatting only
Browse files Browse the repository at this point in the history
  • Loading branch information
briedis committed Apr 29, 2016
1 parent 37fb92f commit 832d5e6
Show file tree
Hide file tree
Showing 32 changed files with 1,485 additions and 1,357 deletions.
27 changes: 15 additions & 12 deletions examples/ExampleGetUserRequest.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,24 @@
use Briedis\ApiBuilder\Method;
use Briedis\ApiBuilder\StructureBuilder;

class ExampleGetUserRequest extends Method{
const URI = 'user/get';
class ExampleGetUserRequest extends Method
{
const URI = 'user/get';

const METHOD = 'GET';
const METHOD = 'GET';

public $title = 'User information';
public $title = 'User information';

public $description = 'Get user by given ids. One or multiple users can be fetched at once';
public $description = 'Get user by given ids. One or multiple users can be fetched at once';

public function getRequest(){
return new GetUsersStructure;
}
public function getRequest()
{
return new GetUsersStructure;
}

public function getResponse(){
return (new StructureBuilder)
->struct('users', new UserStructure, 'Array with user objects')->multiple();
}
public function getResponse()
{
return (new StructureBuilder)
->struct('users', new UserStructure, 'Array with user objects')->multiple();
}
}
10 changes: 5 additions & 5 deletions examples/index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@
$presenter = new Presenter;

// Set a translation callback, if needed
$presenter->setTranslateCallback(function ($key){
return $key; // Call your trans() function
$presenter->setTranslateCallback(function ($key) {
return $key; // Call your trans() function
});

$presenter->add(new ExampleGetUserRequest);
Expand All @@ -21,12 +21,12 @@
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap-theme.min.css">
</head>
<body>
<div class="container">
<?= $presenter->render(); ?>
<?= $presenter->render(); ?>
</div>
</body>
</html>
24 changes: 13 additions & 11 deletions examples/structures/request/GetUsersStructure.php
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
use Briedis\ApiBuilder\StructureBuilder;
use Briedis\ApiBuilder\StructureInterface;

class GetUsersStructure implements StructureInterface {
/**
* Get the structure object
* @return \Briedis\ApiBuilder\StructureBuilder
*/
public function getStructure(){
return (new StructureBuilder)
->int('userId', 'Array of user ids you want to fetch')->multiple()
->int('offset', 'For paging purposes')->optional()
->int('count', 'Amount of users to fetch. Defaults to 20')->optional();
}
class GetUsersStructure implements StructureInterface
{
/**
* Get the structure object
* @return \Briedis\ApiBuilder\StructureBuilder
*/
public function getStructure()
{
return (new StructureBuilder)
->int('userId', 'Array of user ids you want to fetch')->multiple()
->int('offset', 'For paging purposes')->optional()
->int('count', 'Amount of users to fetch. Defaults to 20')->optional();
}
}
22 changes: 12 additions & 10 deletions examples/structures/response/LocationStructure.php
Original file line number Diff line number Diff line change
@@ -1,16 +1,18 @@
<?php


use Briedis\ApiBuilder\StructureInterface;
use Briedis\ApiBuilder\StructureBuilder;
use Briedis\ApiBuilder\StructureInterface;

class LocationStructure implements StructureInterface {
/**
* @return \Briedis\ApiBuilder\StructureBuilder
*/
public function getStructure(){
return (new StructureBuilder('Location'))
->float('lat', 'Latitude coordinate, in decimal format')
->float('lon', 'Longitude coordinate, in decimal format');
}
class LocationStructure implements StructureInterface
{
/**
* @return \Briedis\ApiBuilder\StructureBuilder
*/
public function getStructure()
{
return (new StructureBuilder('Location'))
->float('lat', 'Latitude coordinate, in decimal format')
->float('lon', 'Longitude coordinate, in decimal format');
}
}
36 changes: 19 additions & 17 deletions examples/structures/response/UserStructure.php
Original file line number Diff line number Diff line change
@@ -1,23 +1,25 @@
<?php


use Briedis\ApiBuilder\StructureInterface;
use Briedis\ApiBuilder\StructureBuilder;
use Briedis\ApiBuilder\StructureInterface;

class UserStructure implements StructureInterface{
/**
* Get User structure object
* @return StructureBuilder
*/
public function getStructure(){
return (new StructureBuilder('User'))
->int('id', 'Unique identifier')
->str('username', 'Nickname that will be used in the system')
->str('firstName', 'Users first name')
->str('lastName', 'Users last name')
->str('gender', 'M - male, F - female')->values(['M', 'F'])->optional()
->int('signature', 'Provide your favorite quote or something, if you want')->optional()
->struct('location', new LocationStructure, 'Location object for the user')->optional()
->int('createdAt', 'Unix timestamp, when user has registered');
}
class UserStructure implements StructureInterface
{
/**
* Get User structure object
* @return StructureBuilder
*/
public function getStructure()
{
return (new StructureBuilder('User'))
->int('id', 'Unique identifier')
->str('username', 'Nickname that will be used in the system')
->str('firstName', 'Users first name')
->str('lastName', 'Users last name')
->str('gender', 'M - male, F - female')->values(['M', 'F'])->optional()
->int('signature', 'Provide your favorite quote or something, if you want')->optional()
->struct('location', new LocationStructure, 'Location object for the user')->optional()
->int('createdAt', 'Unix timestamp, when user has registered');
}
}
56 changes: 30 additions & 26 deletions src/Briedis/ApiBuilder/ApiBuilderLaravel4ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,33 +2,37 @@

use Illuminate\Support\ServiceProvider;

class ApiBuilderLaravel4ServiceProvider extends ServiceProvider{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;
class ApiBuilderLaravel4ServiceProvider extends ServiceProvider
{
/**
* Indicates if loading of the provider is deferred.
*
* @var bool
*/
protected $defer = false;

/**
* Register the service provider.
*
* @return void
*/
public function register(){
//
}
/**
* Register the service provider.
*
* @return void
*/
public function register()
{
//
}

/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides(){
return array();
}
/**
* Get the services provided by the provider.
*
* @return array
*/
public function provides()
{
return [];
}

public function boot(){
$this->package('briedis/api-builder');
}
public function boot()
{
$this->package('briedis/api-builder');
}
}
30 changes: 17 additions & 13 deletions src/Briedis/ApiBuilder/ApiBuilderLaravel5ServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,24 @@

use Illuminate\Support\ServiceProvider;

class ApiBuilderLaravel5ServiceProvider extends ServiceProvider{
protected $defer = false;
class ApiBuilderLaravel5ServiceProvider extends ServiceProvider
{
protected $defer = false;

public function register(){
}
public function register()
{
}

public function provides(){
return array();
}
public function provides()
{
return [];
}

public function boot(){
$this->loadViewsFrom(__DIR__ . '/../../views/', 'api-builder');
$this->publishes(array(
__DIR__ . '/../../../public' => public_path('/packages/briedis/api-builder/'),
));
}
public function boot()
{
$this->loadViewsFrom(__DIR__ . '/../../views/', 'api-builder');
$this->publishes([
__DIR__ . '/../../../public' => public_path('/packages/briedis/api-builder/'),
]);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@

use Briedis\ApiBuilder\Items\BaseItem;

class InvalidParameterTypeException extends \Exception{
/** @var BaseItem */
public $expectedItem;
class InvalidParameterTypeException extends \Exception
{
/** @var BaseItem */
public $expectedItem;
}
Loading

0 comments on commit 832d5e6

Please sign in to comment.