mirror of
https://github.com/cerbero90/json-parser.git
synced 2025-01-29 10:38:09 +01:00
Implement pointers
This commit is contained in:
parent
e42ff04cda
commit
5329d51bc1
@ -43,16 +43,6 @@ class Pointers implements Countable
|
||||
$this->defaultPointer = new NullPointer();
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the number of JSON pointers
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->pointers);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the pointer matching the given tree
|
||||
*
|
||||
@ -80,13 +70,13 @@ class Pointers implements Countable
|
||||
* Mark the given pointer as found
|
||||
*
|
||||
* @param Pointer $pointer
|
||||
* @return void
|
||||
* @return static
|
||||
*/
|
||||
public function markAsFound(Pointer $pointer): void
|
||||
public function markAsFound(Pointer $pointer): static
|
||||
{
|
||||
$key = (string) $pointer;
|
||||
$this->found[(string) $pointer] = true;
|
||||
|
||||
$this->found[$key] = true;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -96,6 +86,17 @@ class Pointers implements Countable
|
||||
*/
|
||||
public function wereFound(): bool
|
||||
{
|
||||
return count($this->pointers) == count($this->found);
|
||||
return $this->count() > 0
|
||||
&& $this->count() == count($this->found);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieve the number of JSON pointers
|
||||
*
|
||||
* @return int
|
||||
*/
|
||||
public function count(): int
|
||||
{
|
||||
return count($this->pointers);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user