Skip to content

Commit dff456c

Browse files
authored
Merge pull request #89 from async-interop/state
Rename fetch/storeState to get/setState
2 parents 4bdc40e + 74e2577 commit dff456c

File tree

3 files changed

+17
-19
lines changed

3 files changed

+17
-19
lines changed

src/Loop.php

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -307,26 +307,26 @@ public static function unreference($watcherId)
307307
*
308308
* @return void
309309
*/
310-
public static function storeState($key, $value)
310+
public static function setState($key, $value)
311311
{
312312
$driver = self::$driver ?: self::get();
313-
$driver->storeState($key, $value);
313+
$driver->setState($key, $value);
314314
}
315315

316316
/**
317-
* Fetches information stored bound to the loop. Stored information is package private. Packages MUST NOT retrieve
318-
* the stored state of other packages.
317+
* Gets information stored bound to the loop. Stored information is package private. Packages MUST NOT retrieve the
318+
* stored state of other packages.
319319
*
320320
* Therefore packages SHOULD use the following prefix to keys: `vendor.package.`
321321
*
322322
* @param string $key namespaced storage key
323323
*
324324
* @return mixed previously stored value or null if it doesn't exist
325325
*/
326-
public static function fetchState($key)
326+
public static function getState($key)
327327
{
328328
$driver = self::$driver ?: self::get();
329-
return $driver->fetchState($key);
329+
return $driver->getState($key);
330330
}
331331

332332
/**

src/Loop/Driver.php

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ abstract public function unreference($watcherId);
194194
*
195195
* @return void
196196
*/
197-
final public function storeState($key, $value)
197+
final public function setState($key, $value)
198198
{
199199
if ($value === null) {
200200
unset($this->registry[$key]);
@@ -204,16 +204,16 @@ final public function storeState($key, $value)
204204
}
205205

206206
/**
207-
* Fetches information stored bound to the loop. Stored information is package private. Packages MUST NOT retrieve
208-
* the stored state of other packages.
207+
* Gets information stored bound to the loop. Stored information is package private. Packages MUST NOT retrieve the
208+
* stored state of other packages.
209209
*
210210
* Therefore packages SHOULD use the following prefix to keys: `vendor.package.`
211211
*
212212
* @param string $key namespaced storage key
213213
*
214214
* @return mixed previously stored value or null if it doesn't exist
215215
*/
216-
final public function fetchState($key)
216+
final public function getState($key)
217217
{
218218
return isset($this->registry[$key]) ? $this->registry[$key] : null;
219219
}

test/RegistryTest.php renamed to test/LoopStateTest.php

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

33
namespace Interop\Async\Loop;
44

5-
class RegistryTest extends \PHPUnit_Framework_TestCase
5+
class LoopStateTest extends \PHPUnit_Framework_TestCase
66
{
7-
private $registry;
7+
private $loop;
88

99
protected function setUp()
1010
{
11-
$this->registry = $this->getMockForAbstractClass(Driver::class);
11+
$this->loop = $this->getMockForAbstractClass(Driver::class);
1212
}
1313

1414
/** @test */
1515
public function defaultsToNull()
1616
{
17-
$this->assertNull($this->registry->fetchState("foobar"));
17+
$this->assertNull($this->loop->getState("foobar"));
1818
}
1919

2020
/**
2121
* @test
2222
* @dataProvider provideValues
2323
*/
24-
public function fetchesStoredValue($value)
24+
public function getsPreviouslySetValue($value)
2525
{
26-
$this->assertNull($this->registry->fetchState("foobar"));
27-
$this->registry->storeState("foobar", $value);
28-
29-
$this->assertSame($value, $this->registry->fetchState("foobar"));
26+
$this->loop->setState("foobar", $value);
27+
$this->assertSame($value, $this->loop->getState("foobar"));
3028
}
3129

3230
public function provideValues()

0 commit comments

Comments
 (0)