Skip to content

Commit ce1ec69

Browse files
committed
Minor code refactoring and configuration.
1 parent 2377cd7 commit ce1ec69

File tree

8 files changed

+25
-24
lines changed

8 files changed

+25
-24
lines changed

.codeclimate.yml

+1
Original file line numberDiff line numberDiff line change
@@ -13,4 +13,5 @@ ratings:
1313
paths:
1414
- "**.php"
1515
exclude_paths:
16+
- build/
1617
- tests/

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# PHP JSON Pointer
22

3-
[![Build Status](https://travis-ci.org/remorhaz/php-json-pointer.svg?branch=master)](https://travis-ci.org/remorhaz/php-json-pointer)
43
[![Latest Stable Version](https://poser.pugx.org/remorhaz/php-json-pointer/v/stable)](https://packagist.org/packages/remorhaz/php-json-pointer)
54
[![License](https://poser.pugx.org/remorhaz/php-json-pointer/license)](https://packagist.org/packages/remorhaz/php-json-pointer)
5+
[![Build Status](https://travis-ci.org/remorhaz/php-json-pointer.svg?branch=master)](https://travis-ci.org/remorhaz/php-json-pointer)
66
[![Code Climate](https://codeclimate.com/github/remorhaz/php-json-pointer/badges/gpa.svg)](https://codeclimate.com/github/remorhaz/php-json-pointer)
77
[![Test Coverage](https://codeclimate.com/github/remorhaz/php-json-pointer/badges/coverage.svg)](https://codeclimate.com/github/remorhaz/php-json-pointer/coverage)
88

phpunit.xml

+4-2
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,14 @@
33
bootstrap="vendor/autoload.php"
44
colors="true">
55
<testsuites>
6-
<testsuite name="Library Test Suite">
6+
<testsuite name="Full Test Suite">
77
<directory>tests/</directory>
88
</testsuite>
99
</testsuites>
1010
<filter>
11-
<whitelist>
11+
<whitelist
12+
getUncoveredFilesFromWhitelist="true"
13+
processUncoveredFilesFromWhitelist="true">
1214
<directory suffix=".php">src/</directory>
1315
</whitelist>
1416
</filter>

src/Locator.php

+5-7
Original file line numberDiff line numberDiff line change
@@ -57,17 +57,15 @@ public function getReferenceList()
5757
public function addReference(Locator\Reference $reference)
5858
{
5959
$this->referenceList[] = $reference;
60-
if (null === $this->lastReference) {
61-
$pathPrefix = '';
62-
} else {
63-
$pathPrefix = $this
60+
$pathPrefix = null === $this->lastReference
61+
? ''
62+
: $this
6463
->lastReference
65-
->setLast(false)
64+
->setIsLast(false)
6665
->getPath();
67-
}
6866

6967
$this->lastReference = $reference
70-
->setLast()
68+
->setIsLast()
7169
->setPath("{$pathPrefix}/{$reference->getText()}");
7270
return $this;
7371
}

src/Locator/Reference.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -173,12 +173,12 @@ public function isLast()
173173
}
174174

175175

176-
public function setLast($on = true)
176+
public function setIsLast($isLast = true)
177177
{
178-
if (!is_bool($on)) {
178+
if (!is_bool($isLast)) {
179179
throw new Reference\InvalidArgumentException("Reference value must be boolean");
180180
}
181-
$this->isLast = $on;
181+
$this->isLast = $isLast;
182182
return $this;
183183
}
184184

src/Pointer.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ public function unsetData()
134134
public function test()
135135
{
136136
return Pointer\Evaluate\Test::factory()
137-
->setAllowedNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
137+
->setNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
138138
->setLocator($this->getLocator())
139139
->setData($this->getData())
140140
->perform()
@@ -144,7 +144,7 @@ public function test()
144144
public function &read()
145145
{
146146
return Pointer\Evaluate\Read::factory()
147-
->setAllowedNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
147+
->setNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
148148
->setLocator($this->getLocator())
149149
->setData($this->getData())
150150
->perform()
@@ -155,7 +155,7 @@ public function &read()
155155
public function write($value)
156156
{
157157
Pointer\Evaluate\Write::factory()
158-
->setAllowedNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
158+
->setNonNumericArrayIndices($this->hasOption(self::OPTION_NON_NUMERIC_ARRAY_INDICES))
159159
->setLocator($this->getLocator())
160160
->setData($this->getData())
161161
->setValue($value)

src/Pointer/Evaluate.php

+5-5
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ abstract class Evaluate
5555
*/
5656
protected $result;
5757

58-
protected $areAllowedNonNumericArrayIndices = false;
58+
protected $nonNumericArrayIndices = false;
5959

6060

6161
/**
@@ -176,12 +176,12 @@ public function &getResult()
176176
}
177177

178178

179-
public function setAllowedNonNumericArrayIndices($on = true)
179+
public function setNonNumericArrayIndices($allow = true)
180180
{
181-
if (!is_bool($on)) {
181+
if (!is_bool($allow)) {
182182
throw new Evaluate\InvalidArgumentException("Non-numeric array indices allowance flag must be boolean");
183183
}
184-
$this->areAllowedNonNumericArrayIndices = $on;
184+
$this->nonNumericArrayIndices = $allow;
185185
return $this;
186186
}
187187

@@ -267,7 +267,7 @@ protected function processArrayIndex(Reference $reference)
267267
return $this->processNumericArrayIndex($reference);
268268

269269
default:
270-
return $this->areAllowedNonNumericArrayIndices
270+
return $this->nonNumericArrayIndices
271271
? $this->processAllowedNonNumericArrayIndex($reference)
272272
: $this->processNotAllowedNonNumericArrayIndex($reference);
273273
}

tests/Locator/Reference/IsLastTest.php

+3-3
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ public function testAccessingUninitializedIsLastThrowsSplException()
3232
*/
3333
public function testGotIsLastSameAsSet($on)
3434
{
35-
$reference = Reference::factory()->setLast($on);
35+
$reference = Reference::factory()->setIsLast($on);
3636
$this->assertSame($on, $reference->isLast(), "Got last reference flag differs from the one that was set");
3737
}
3838

@@ -51,7 +51,7 @@ public function providerGotIsLastSameAsSet()
5151
*/
5252
public function testSetNotBooleanLastThrowsException()
5353
{
54-
Reference::factory()->setLast(0);
54+
Reference::factory()->setIsLast(0);
5555
}
5656

5757

@@ -60,6 +60,6 @@ public function testSetNotBooleanLastThrowsException()
6060
*/
6161
public function testSetNotBooleanLastThrowsSplException()
6262
{
63-
Reference::factory()->setLast(0);
63+
Reference::factory()->setIsLast(0);
6464
}
6565
}

0 commit comments

Comments
 (0)