Skip to content

Commit 3a2eeef

Browse files
committed
Remove internal "arguments" terminology
The original version of much of the interal Brief documentation used "argument(s)" to refer to data stored on the Brief. This was influenced by some of the original intent, but I've come to feel that--especially with the introduction of more callables--this terminology serves only to confuse the documentation. Hence I have switched to using, simply, "data" to describe the data stored in a Brief, and "store" to refer to the location where that data is stored.
1 parent 6b0842a commit 3a2eeef

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

src/Brief.php

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,14 @@ class Brief
77
*
88
* @var array
99
*/
10-
private $arguments = [];
10+
private $store = [];
1111

1212
/**
1313
* A limited list of terms that cannot be used as argument keys.
1414
*
1515
* @var array|object
1616
*/
17-
static $protected = ['protected', 'arguments', 'aliases', 'logger'];
17+
static $protected = ['protected', 'store', 'aliases', 'logger', 'callables'];
1818

1919
/**
2020
* An array of aliases for internal terms. The key is the alias; the value
@@ -251,7 +251,7 @@ protected function storeSingle($value, string $key = null, int $order = null): s
251251
$key = $this->getAuthoritativeName($key) ?? $key;
252252
}
253253

254-
$this->arguments[$key] = [
254+
$this->store[$key] = [
255255
'value' => $value,
256256
'order' => $order
257257
];
@@ -303,7 +303,7 @@ public static function isKeyAllowed($key)
303303
*/
304304
public function __isset($name)
305305
{
306-
return in_array($name, array_keys($this->arguments));
306+
return in_array($name, array_keys($this->store));
307307
}
308308

309309
/**
@@ -342,8 +342,8 @@ public function __set(string $name, $value)
342342
*/
343343
protected function getArgument($name)
344344
{
345-
return isset($this->arguments[$name])
346-
? $this->getValue($this->arguments[$name])
345+
return isset($this->store[$name])
346+
? $this->getValue($this->store[$name])
347347
: null;
348348
}
349349

@@ -361,7 +361,7 @@ protected function getArgument($name)
361361
*/
362362
protected function getAuthoritativeName($name)
363363
{
364-
if (isset($this->arguments[$name])) {
364+
if (isset($this->store[$name])) {
365365
return $name;
366366
}
367367

@@ -388,9 +388,9 @@ protected function getValue($item)
388388
*
389389
* @return array
390390
*/
391-
protected function getArgumentsSortedByOrder()
391+
protected function getDataSortedByOrder()
392392
{
393-
$rekeyed = array_column($this->arguments, null, 'order');
393+
$rekeyed = array_column($this->store, null, 'order');
394394
ksort($rekeyed);
395395

396396
return $rekeyed;
@@ -408,7 +408,7 @@ protected function getArgumentsSortedByOrder()
408408
*/
409409
protected function getOrderLimit(string $which = 'start', string $attribute = null)
410410
{
411-
$ordered = $this->getArgumentsSortedByOrder();
411+
$ordered = $this->getDataSortedByOrder();
412412
if ('start' === $which) {
413413
$limit = reset($ordered);
414414
} else { // i.e. 'end'
@@ -462,7 +462,7 @@ protected function getIncrementedOrder(): int
462462
*/
463463
protected function getFilledOrdered($fill = null)
464464
{
465-
$orders = $this->getArgumentsSortedByOrder();
465+
$orders = $this->getDataSortedByOrder();
466466

467467
return array_map(function ($key) use ($orders, $fill) {
468468
return $orders[$key] ?? ['order' => $key, 'value' => $fill];
@@ -483,21 +483,21 @@ public function getOrdered($fill = null)
483483
}
484484

485485
/**
486-
* Get all arguments in this Brief as a keyed array.
486+
* Get all data in this Brief as a keyed array.
487487
*
488488
* @return array
489489
*/
490490
public function getKeyed()
491491
{
492492
return array_map(function ($block) {
493493
return $block['value'];
494-
}, $this->arguments);
494+
}, $this->store);
495495
}
496496

497497
/**
498498
* Pass an unmodified Brief to an callable.
499499
*
500-
* If the callable does not understand Briefs or how to get arguments from
500+
* If the callable does not understand Briefs or how to get properties from
501501
* objects, you should probably use `pass()` instead.
502502
*
503503
* @param callable $callable
@@ -510,7 +510,7 @@ public function debrief(callable $callable)
510510
}
511511

512512
/**
513-
* Pass the contents of a Brief as a series of arguments to callable.
513+
* Pass the contents of a Brief as a series of arguments to a callable.
514514
*
515515
* This method allows for Brief to easily interact with methods that do not
516516
* know how to handle it specifically.
@@ -578,8 +578,8 @@ public function find($keys)
578578
/**
579579
* Call a callable on each item of this Brief.
580580
*
581-
* This is method is intended for use with keyed arguments. Ordered
582-
* arguments may produce strange results.
581+
* This is method is intended for use with keyed data. Ordered
582+
* data may produce strange results.
583583
*
584584
* This acts directly on the Brief on which it is called, and returns that
585585
* Brief. Be careful; this means that your original Brief is changed. If
@@ -601,8 +601,8 @@ public function transform(callable $callable)
601601
/**
602602
* Call a callable on each item of a copy of this Brief.
603603
*
604-
* This is method is intended for use with keyed arguments. Ordered
605-
* arguments may produce strange results.
604+
* This is method is intended for use with keyed data. Ordered
605+
* data may produce strange results.
606606
*
607607
* This acts on a copy of the Brief on which it is called, and returns the
608608
* new Brief, leaving the original unmodified. If you don't want this
@@ -690,7 +690,7 @@ public function log(string $name, string $description = null, array $data = [])
690690
public function export()
691691
{
692692
return [
693-
'arguments' => $this->arguments,
693+
'store' => $this->store,
694694
'aliases' => $this->aliases,
695695
'callables' => $this->callables,
696696
];
@@ -710,11 +710,11 @@ public function export()
710710
protected function import(Brief $items, $settings)
711711
{
712712
[
713-
'arguments' => $arguments,
713+
'store' => $store,
714714
'aliases' => $aliases,
715715
'callables' => $callables
716716
] = $items->export();
717-
$this->arguments = $arguments;
717+
$this->store = $store;
718718
$this->aliases = $aliases;
719719
$this->callables = $callables;
720720
if (is_array($settings) && count($settings) > 0) {

0 commit comments

Comments
 (0)