diff options
| author | David T. Sadler <davidtsadler@googlemail.com> | 2021-11-08 20:50:15 +0000 | 
|---|---|---|
| committer | David T. Sadler <davidtsadler@googlemail.com> | 2021-11-08 20:50:15 +0000 | 
| commit | 4a40b41f386af23da54cd35b8abac1f27c8e5ef7 (patch) | |
| tree | e618372a6f5446adc9e3770607cbb5fb04377900 /src/DTS | |
| parent | 745664a1bf36cce13f3439698275b0b147efde3b (diff) | |
Filter by tag
Diffstat (limited to 'src/DTS')
| -rw-r--r-- | src/DTS/BookmarkRepository.php | 13 | 
1 files changed, 13 insertions, 0 deletions
diff --git a/src/DTS/BookmarkRepository.php b/src/DTS/BookmarkRepository.php index 01f6de4..fde8510 100644 --- a/src/DTS/BookmarkRepository.php +++ b/src/DTS/BookmarkRepository.php @@ -12,6 +12,8 @@ class BookmarkRepository implements \Iterator      private array $repository = []; +    private array $tags = []; +      private int $position = 0;      function __construct(string $pathToRepository) @@ -75,6 +77,11 @@ class BookmarkRepository implements \Iterator          return false;      } +    public function tags(): array +    { +        return $this->tags; +    } +      public function current(): mixed      {          return $this->repository[$this->position]; @@ -122,8 +129,14 @@ class BookmarkRepository implements \Iterator              $bookmark->addedAt = $data[3];              $this->repository[] = $bookmark; + +            $this->tags[] = $bookmark->tag;          } +        $this->tags = array_filter(array_unique($this->tags)); + +        sort($this->tags); +          fclose($fp);      }  | 
