Skip to content

Commit f16d255

Browse files
committed
Rename config to properties for a bit of consistency.
Signed-off-by: Jason Lewis <[email protected]>
1 parent fea28bf commit f16d255

File tree

9 files changed

+43
-43
lines changed

9 files changed

+43
-43
lines changed

src/Dispatcher.php

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -56,11 +56,11 @@ class Dispatcher
5656
protected $auth;
5757

5858
/**
59-
* API config instance.
59+
* API properties instance.
6060
*
61-
* @var \Dingo\Api\Config
61+
* @var \Dingo\Api\Properties
6262
*/
63-
protected $config;
63+
protected $properties;
6464

6565
/**
6666
* Internal request stack.
@@ -147,18 +147,18 @@ class Dispatcher
147147
* @param \Illuminate\Routing\UrlGenerator $url
148148
* @param \Dingo\Api\Routing\Router $router
149149
* @param \Dingo\Api\Auth\Authenticator $auth
150-
* @param \Dingo\Api\Config $config
150+
* @param \Dingo\Api\Properties $properties
151151
*
152152
* @return void
153153
*/
154-
public function __construct(Container $container, Filesystem $files, UrlGenerator $url, Router $router, Authenticator $auth, Config $config)
154+
public function __construct(Container $container, Filesystem $files, UrlGenerator $url, Router $router, Authenticator $auth, Properties $properties)
155155
{
156156
$this->container = $container;
157157
$this->files = $files;
158158
$this->url = $url;
159159
$this->router = $router;
160160
$this->auth = $auth;
161-
$this->config = $config;
161+
$this->properties = $properties;
162162

163163
$this->setupRequestStack();
164164
}
@@ -343,7 +343,7 @@ public function cookie(Cookie $cookie)
343343
*/
344344
public function route($name, $parameters = [], $requestParameters = [])
345345
{
346-
$version = $this->version ?: $this->config->getVersion();
346+
$version = $this->version ?: $this->properties->getVersion();
347347

348348
$route = $this->router->getApiGroups()->getByDomainOrVersion($this->domain, $version)->getByName($name);
349349

@@ -361,7 +361,7 @@ public function route($name, $parameters = [], $requestParameters = [])
361361
*/
362362
public function action($action, $parameters = [], $requestParameters = [])
363363
{
364-
$version = $this->version ?: $this->config->getVersion();
364+
$version = $this->version ?: $this->properties->getVersion();
365365

366366
$route = $this->router->getApiGroups()->getByDomainOrVersion($this->domain, $version)->getByAction($action);
367367

@@ -487,7 +487,7 @@ protected function queueRequest($verb, $uri, $parameters, $content = '')
487487
protected function createRequest($verb, $uri, $parameters)
488488
{
489489
if (! isset($this->version)) {
490-
$this->version = $this->config->getVersion();
490+
$this->version = $this->properties->getVersion();
491491
}
492492

493493
$api = $this->router->getApiGroups()->getByDomainOrVersion($this->domain, $this->version);
@@ -520,7 +520,7 @@ protected function createRequest($verb, $uri, $parameters)
520520
*/
521521
protected function buildAcceptHeader()
522522
{
523-
return sprintf('application/vnd.%s.%s+%s', $this->config->getVendor(), $this->version, $this->config->getFormat());
523+
return sprintf('application/vnd.%s.%s+%s', $this->properties->getVendor(), $this->version, $this->properties->getFormat());
524524
}
525525

526526
/**

src/Config.php renamed to src/Properties.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Dingo\Api;
44

5-
class Config
5+
class Properties
66
{
77
/**
88
* API version.
@@ -40,7 +40,7 @@ class Config
4040
protected $format;
4141

4242
/**
43-
* Create a new config instance.
43+
* Create a new properties instance.
4444
*
4545
* @param string $version
4646
* @param string $prefix

src/Routing/GroupCollection.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,17 @@
22

33
namespace Dingo\Api\Routing;
44

5-
use Dingo\Api\Config;
5+
use Dingo\Api\Properties;
66
use Illuminate\Http\Request;
77

88
class GroupCollection
99
{
1010
/**
11-
* API config instance.
11+
* API properties instance.
1212
*
13-
* @var \Dingo\Api\Config
13+
* @var \Dingo\Api\Properties
1414
*/
15-
protected $config;
15+
protected $properties;
1616

1717
/**
1818
* Array of API route collections.
@@ -31,13 +31,13 @@ class GroupCollection
3131
/**
3232
* Create a new version collection instance.
3333
*
34-
* @param \Dingo\Api\Config $config
34+
* @param \Dingo\Api\Properties $properties
3535
*
3636
* @return void
3737
*/
38-
public function __construct(Config $config)
38+
public function __construct(Properties $properties)
3939
{
40-
$this->config = $config;
40+
$this->properties = $properties;
4141
}
4242

4343
/**
@@ -88,7 +88,7 @@ public function getByRequest(Request $request)
8888
*/
8989
public function getDefault()
9090
{
91-
return $this->getByVersion($this->config->getVersion());
91+
return $this->getByVersion($this->properties->getVersion());
9292
}
9393

9494
/**

src/Routing/Router.php

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Dingo\Api\Routing;
44

55
use Exception;
6-
use Dingo\Api\Config;
6+
use Dingo\Api\Properties;
77
use BadMethodCallException;
88
use Illuminate\Http\Request;
99
use Illuminate\Events\Dispatcher;
@@ -23,11 +23,11 @@
2323
class Router extends IlluminateRouter
2424
{
2525
/**
26-
* API config instance.
26+
* API properties instance.
2727
*
28-
* @var \Dingo\Api\Config
28+
* @var \Dingo\Api\Properties
2929
*/
30-
protected $config;
30+
protected $properties;
3131

3232
/**
3333
* API version collection instance.
@@ -75,15 +75,15 @@ class Router extends IlluminateRouter
7575
* Create a new router instance.
7676
*
7777
* @param \Illuminate\Events\Dispatcher $events
78-
* @param \Dingo\Api\Routing\Config $config
78+
* @param \Dingo\Api\Properties $properties
7979
* @param \Illuminate\Container\Container $container
8080
*
8181
* @return void
8282
*/
83-
public function __construct(Dispatcher $events, Config $config, Container $container = null)
83+
public function __construct(Dispatcher $events, Properties $properties, Container $container = null)
8484
{
85-
$this->config = $config;
86-
$this->api = new GroupCollection($config);
85+
$this->properties = $properties;
86+
$this->api = new GroupCollection($properties);
8787

8888
parent::__construct($events, $container);
8989
}
@@ -140,11 +140,11 @@ protected function setupGroupOptions($options)
140140

141141
$options['version'] = (array) $options['version'];
142142

143-
if (! isset($options['prefix']) && $prefix = $this->config->getPrefix()) {
143+
if (! isset($options['prefix']) && $prefix = $this->properties->getPrefix()) {
144144
$options['prefix'] = $prefix;
145145
}
146146

147-
if (! isset($options['domain']) && $domain = $this->config->getDomain()) {
147+
if (! isset($options['domain']) && $domain = $this->properties->getDomain()) {
148148
$options['domain'] = $domain;
149149
}
150150

@@ -229,7 +229,7 @@ public function dispatch(Request $request, $morph = true)
229229
// most likely formatting an error response.
230230
if ($morph) {
231231
if (! $response->hasFormatter($format)) {
232-
$format = $this->config->getFormat();
232+
$format = $this->properties->getFormat();
233233
}
234234

235235
$response->getFormatter($format)
@@ -403,13 +403,13 @@ public function isApiRequest($request)
403403
*/
404404
protected function parseAcceptHeader(Request $request)
405405
{
406-
if (preg_match('#application/vnd\.'.$this->config->getVendor().'.(v[\d\.]+)\+(\w+)#', $request->header('accept'), $matches)) {
406+
if (preg_match('#application/vnd\.'.$this->properties->getVendor().'.(v[\d\.]+)\+(\w+)#', $request->header('accept'), $matches)) {
407407
return array_slice($matches, 1);
408408
} elseif ($this->isStrict()) {
409409
throw new InvalidAcceptHeaderException('Unable to match the "Accept" header for the API request.');
410410
}
411411

412-
return [$this->config->getVersion(), $this->config->getFormat()];
412+
return [$this->properties->getVersion(), $this->properties->getFormat()];
413413
}
414414

415415
/**

tests/Auth/AuthenticatorTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Dingo\Api\Tests\Auth;
44

55
use Mockery;
6-
use Dingo\Api\Config;
6+
use Dingo\Api\Properties;
77
use Illuminate\Http\Request;
88
use Dingo\Api\Routing\Route;
99
use Dingo\Api\Routing\Router;
@@ -18,7 +18,7 @@ class AuthenticatorTest extends PHPUnit_Framework_TestCase
1818
public function setUp()
1919
{
2020
$this->container = new Container;
21-
$this->router = new Router(Mockery::mock('Illuminate\Events\Dispatcher'), new Config, $this->container);
21+
$this->router = new Router(Mockery::mock('Illuminate\Events\Dispatcher'), new Properties, $this->container);
2222
}
2323

2424
/**

tests/DispatcherTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Dingo\Api\Tests;
44

55
use Mockery;
6-
use Dingo\Api\Config;
6+
use Dingo\Api\Properties;
77
use Dingo\Api\Dispatcher;
88
use Illuminate\Http\Request;
99
use Dingo\Api\Http\Response;
@@ -23,7 +23,7 @@ class DispatcherTest extends PHPUnit_Framework_TestCase
2323
{
2424
public function setUp()
2525
{
26-
$config = new Config('v1', null, null, 'test');
26+
$config = new Properties('v1', null, null, 'test');
2727
$this->container = new Container;
2828
$this->container['request'] = Request::create('/', 'GET');
2929
$url = new UrlGenerator(new RouteCollection, $this->container['request']);

tests/Http/Filter/AuthFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Dingo\Api\Tests\Http\Filter;
44

55
use Mockery;
6-
use Dingo\Api\Config;
6+
use Dingo\Api\Properties;
77
use Illuminate\Http\Request;
88
use Dingo\Api\Routing\Route;
99
use Dingo\Api\Routing\Router;
@@ -19,7 +19,7 @@ public function setUp()
1919
{
2020
$this->container = new Container;
2121
$this->events = new Dispatcher($this->container);
22-
$this->router = new Router($this->events, new Config, $this->container);
22+
$this->router = new Router($this->events, new Properties, $this->container);
2323
$this->auth = Mockery::mock('Dingo\Api\Auth\Authenticator');
2424
$this->filter = new AuthFilter($this->router, $this->events, $this->auth);
2525
}

tests/Http/Filter/RateLimitFilterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
namespace Dingo\Api\Tests\Http\Filter;
44

5-
use Dingo\Api\Config;
5+
use Dingo\Api\Properties;
66
use Illuminate\Http\Request;
77
use Dingo\Api\Routing\Route;
88
use Dingo\Api\Http\Response;
@@ -23,7 +23,7 @@ public function setUp()
2323
$this->container = new Container;
2424
$this->container['config'] = ['cache.driver' => 'array'];
2525

26-
$this->router = new Router(new Dispatcher($this->container), new Config, $this->container);
26+
$this->router = new Router(new Dispatcher($this->container), new Properties, $this->container);
2727
$this->cache = new CacheManager($this->container);
2828
$this->limiter = new RateLimiter($this->container, $this->cache, []);
2929
$this->filter = new RateLimitFilter($this->router, $this->limiter);

tests/Routing/RouterTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
namespace Dingo\Api\Tests\Routing;
44

55
use Mockery as m;
6-
use Dingo\Api\Config;
6+
use Dingo\Api\Properties;
77
use Illuminate\Http\Request;
88
use Dingo\Api\Http\Response;
99
use Dingo\Api\Routing\Router;
@@ -20,7 +20,7 @@ class RouterTest extends PHPUnit_Framework_TestCase
2020
public function setUp()
2121
{
2222
$this->events = new Dispatcher;
23-
$this->config = new Config('v1', null, null, 'testing', 'json', false);
23+
$this->config = new Properties('v1', null, null, 'testing', 'json', false);
2424

2525
$this->router = new Router($this->events, $this->config);
2626

0 commit comments

Comments
 (0)