Skip to content

Commit 4131dd8

Browse files
author
Raluca Rietkerk
committed
Rename inflect method
1 parent 681a97e commit 4131dd8

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

src/Model/Endpoint.php

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Endpoint implements RepositoryInterface, EventListenerInterface, EventDisp
113113
*
114114
* @var string
115115
*/
116-
protected $_inflect = 'underscore';
116+
protected $_inflection = 'underscore';
117117

118118
/**
119119
* Initializes a new instance
@@ -160,8 +160,8 @@ public function __construct(array $config = [])
160160
if (!empty($config['resourceClass'])) {
161161
$this->resourceClass($config['resourceClass']);
162162
}
163-
if (!empty($config['inflect'])) {
164-
$this->inflect($config['inflect']);
163+
if (!empty($config['inflection'])) {
164+
$this->inflectionMethod($config['inflection']);
165165
}
166166

167167
$this->_eventManager = $eventManager ?: new EventManager();
@@ -227,7 +227,7 @@ public function endpoint($endpoint = null)
227227
if (empty($endpoint)) {
228228
$endpoint = $this->alias();
229229
}
230-
$inflectMethod = $this->inflect();
230+
$inflectMethod = $this->inflectionMethod();
231231
$this->_endpoint = Inflector::$inflectMethod($endpoint);
232232
}
233233

@@ -466,17 +466,17 @@ public function resourceClass($name = null)
466466
/**
467467
* Returns the inflect method or sets a new one
468468
*
469-
* @param null $method
469+
* @param null|string $method The inflection method to use
470470
*
471471
* @return null|string
472472
*/
473-
public function inflect($method = null)
473+
public function inflectionMethod($method = null)
474474
{
475475
if ($method === null) {
476-
return $this->_inflect;
476+
return $this->_inflection;
477477
}
478478

479-
return $this->_inflect = $method;
479+
return $this->_inflection = $method;
480480
}
481481

482482
/**
@@ -835,9 +835,9 @@ public function exists($conditions)
835835
public function save(EntityInterface $resource, $options = [])
836836
{
837837
$options = new ArrayObject($options + [
838-
'checkRules' => true,
839-
'checkExisting' => false,
840-
]);
838+
'checkRules' => true,
839+
'checkExisting' => false,
840+
]);
841841

842842
if ($resource->errors()) {
843843
return false;

tests/TestCase/Model/EndpointTest.php

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public function testEndpoint()
4545
$endpoint = new Endpoint(['alias' => 'UserGroups']);
4646
$this->assertSame('user_groups', $endpoint->endpoint());
4747

48-
$endpoint = new Endpoint(['alias' => 'UserGroups', 'inflect' => 'dasherize']);
48+
$endpoint = new Endpoint(['alias' => 'UserGroups', 'inflection' => 'dasherize']);
4949
$this->assertSame('user-groups', $endpoint->endpoint());
5050
}
5151

@@ -181,7 +181,7 @@ public function testNewEntity()
181181
'title' => 'New entity',
182182
'body' => 'New entity body'
183183
]), $this->endpoint->newEntity([
184-
'title' => 'New entity',
184+
'title' => 'New entity',
185185
'body' => 'New entity body'
186186
]));
187187
}
@@ -240,16 +240,16 @@ public function testConnection()
240240
}
241241

242242
/**
243-
* Tests inflect method
243+
* Tests inflectionMethod method
244244
*
245245
* @return void
246246
*/
247-
public function testInflect()
247+
public function testInflectionMethod()
248248
{
249249
$endpoint = new Endpoint(['endpoint' => 'users']);
250-
$this->assertSame('underscore', $endpoint->inflect());
251-
$endpoint->inflect('dasherize');
252-
$this->assertSame('dasherize', $endpoint->inflect());
250+
$this->assertSame('underscore', $endpoint->inflectionMethod());
251+
$endpoint->inflectionMethod('dasherize');
252+
$this->assertSame('dasherize', $endpoint->inflectionMethod());
253253
}
254254

255255
/**

0 commit comments

Comments
 (0)