├── .github ├── FUNDING.yml ├── ISSUE_TEMPLATE │ └── config.yml └── workflows │ ├── php-cs-fixer.yml │ ├── update-changelog.yml │ └── run-tests.yml ├── .editorconfig ├── LICENSE.md ├── composer.json ├── .php-cs-fixer.dist.php ├── CHANGELOG.md ├── src └── Valuestore.php └── README.md /.github/FUNDING.yml: -------------------------------------------------------------------------------- 1 | github: spatie 2 | custom: https://spatie.be/open-source/support-us 3 | -------------------------------------------------------------------------------- /.editorconfig: -------------------------------------------------------------------------------- 1 | ; This file is for unifying the coding style for different editors and IDEs. 2 | ; More information at http://editorconfig.org 3 | 4 | root = true 5 | 6 | [*] 7 | charset = utf-8 8 | indent_size = 4 9 | indent_style = space 10 | end_of_line = lf 11 | insert_final_newline = true 12 | trim_trailing_whitespace = true 13 | 14 | [*.md] 15 | trim_trailing_whitespace = false 16 | -------------------------------------------------------------------------------- /.github/ISSUE_TEMPLATE/config.yml: -------------------------------------------------------------------------------- 1 | blank_issues_enabled: true 2 | contact_links: 3 | - name: Feature Request 4 | url: https://github.com/spatie/valuestore/discussions/new?category=ideas 5 | about: Share ideas for new features 6 | - name: Ask a Question 7 | url: https://github.com/spatie/valuestore/discussions/new?category=q-a 8 | about: Ask the community for help 9 | -------------------------------------------------------------------------------- /.github/workflows/php-cs-fixer.yml: -------------------------------------------------------------------------------- 1 | name: Check & fix styling 2 | 3 | on: [push] 4 | 5 | jobs: 6 | php-cs-fixer: 7 | runs-on: ubuntu-latest 8 | 9 | steps: 10 | - name: Checkout code 11 | uses: actions/checkout@v2 12 | with: 13 | ref: ${{ github.head_ref }} 14 | 15 | - name: Run PHP CS Fixer 16 | uses: docker://oskarstark/php-cs-fixer-ga 17 | with: 18 | args: --config=.php-cs-fixer.dist.php --allow-risky=yes 19 | 20 | - name: Commit changes 21 | uses: stefanzweifel/git-auto-commit-action@v4 22 | with: 23 | commit_message: Fix styling -------------------------------------------------------------------------------- /.github/workflows/update-changelog.yml: -------------------------------------------------------------------------------- 1 | name: "Update Changelog" 2 | 3 | on: 4 | release: 5 | types: [released] 6 | 7 | jobs: 8 | update: 9 | runs-on: ubuntu-latest 10 | 11 | steps: 12 | - name: Checkout code 13 | uses: actions/checkout@v2 14 | with: 15 | ref: main 16 | 17 | - name: Update Changelog 18 | uses: stefanzweifel/changelog-updater-action@v1 19 | with: 20 | latest-version: ${{ github.event.release.name }} 21 | release-notes: ${{ github.event.release.body }} 22 | 23 | - name: Commit updated CHANGELOG 24 | uses: stefanzweifel/git-auto-commit-action@v4 25 | with: 26 | branch: main 27 | commit_message: Update CHANGELOG 28 | file_pattern: CHANGELOG.md -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | The MIT License (MIT) 2 | 3 | Copyright (c) Spatie bvba 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in 13 | all copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 21 | THE SOFTWARE. 22 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "spatie/valuestore", 3 | "description": "Easily store some values", 4 | "keywords": [ 5 | "spatie", 6 | "valuestore", 7 | "json" 8 | ], 9 | "homepage": "https://github.com/spatie/valuestore", 10 | "license": "MIT", 11 | "authors": [ 12 | { 13 | "name": "Freek Van der Herten", 14 | "email": "freek@spatie.be", 15 | "homepage": "https://spatie.be", 16 | "role": "Developer" 17 | }, 18 | { 19 | "name": "Jolita Grazyte", 20 | "email": "jolita@spatie.be", 21 | "homepage": "https://spatie.be", 22 | "role": "Developer" 23 | } 24 | ], 25 | "require": { 26 | "php" : "^8.0|^8.1" 27 | }, 28 | "require-dev": { 29 | "phpunit/phpunit": "^9.3" 30 | }, 31 | "autoload": { 32 | "psr-4": { 33 | "Spatie\\Valuestore\\": "src" 34 | } 35 | }, 36 | "autoload-dev": { 37 | "psr-4": { 38 | "Spatie\\Valuestore\\Test\\": "tests" 39 | } 40 | }, 41 | "scripts": { 42 | "test": "vendor/bin/phpunit" 43 | } 44 | } 45 | -------------------------------------------------------------------------------- /.github/workflows/run-tests.yml: -------------------------------------------------------------------------------- 1 | name: Tests 2 | 3 | on: 4 | - push 5 | - pull_request 6 | 7 | jobs: 8 | test: 9 | runs-on: ${{ matrix.os }} 10 | 11 | strategy: 12 | fail-fast: true 13 | matrix: 14 | os: [ubuntu-latest, windows-latest] 15 | php: ['8.0', 8.1, 8.2, 8.3, 8.4] 16 | dependency-version: [prefer-lowest, prefer-stable] 17 | 18 | name: P${{ matrix.php }} - ${{ matrix.dependency-version }} - ${{ matrix.os }} 19 | 20 | steps: 21 | - name: Checkout code 22 | uses: actions/checkout@v2 23 | 24 | - name: Cache dependencies 25 | uses: actions/cache@v2 26 | with: 27 | path: ~/.composer/cache/files 28 | key: dependencies-php-${{ matrix.php }}-composer-${{ hashFiles('composer.json') }} 29 | 30 | - name: Setup PHP 31 | uses: shivammathur/setup-php@v2 32 | with: 33 | php-version: ${{ matrix.php }} 34 | extensions: dom, curl, libxml, mbstring, zip, pcntl, pdo, sqlite, pdo_sqlite, bcmath, soap, intl, gd, exif, iconv, imagick 35 | coverage: none 36 | 37 | - name: Install dependencies 38 | run: composer update --${{ matrix.dependency-version }} --prefer-dist --no-interaction --no-suggest 39 | 40 | - name: Execute tests 41 | run: vendor/bin/phpunit 42 | -------------------------------------------------------------------------------- /.php-cs-fixer.dist.php: -------------------------------------------------------------------------------- 1 | in([ 5 | __DIR__ . '/src', 6 | __DIR__ . '/tests', 7 | ]) 8 | ->name('*.php') 9 | ->ignoreDotFiles(true) 10 | ->ignoreVCS(true); 11 | 12 | return (new PhpCsFixer\Config()) 13 | ->setRules([ 14 | '@PSR12' => true, 15 | 'array_syntax' => ['syntax' => 'short'], 16 | 'ordered_imports' => ['sort_algorithm' => 'alpha'], 17 | 'no_unused_imports' => true, 18 | 'not_operator_with_successor_space' => true, 19 | 'trailing_comma_in_multiline' => true, 20 | 'phpdoc_scalar' => true, 21 | 'unary_operator_spaces' => true, 22 | 'binary_operator_spaces' => true, 23 | 'blank_line_before_statement' => [ 24 | 'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'], 25 | ], 26 | 'phpdoc_single_line_var_spacing' => true, 27 | 'phpdoc_var_without_name' => true, 28 | 'class_attributes_separation' => [ 29 | 'elements' => [ 30 | 'method' => 'one', 31 | ], 32 | ], 33 | 'method_argument_space' => [ 34 | 'on_multiline' => 'ensure_fully_multiline', 35 | 'keep_multiple_spaces_after_comma' => true, 36 | ], 37 | 'single_trait_insert_per_statement' => true, 38 | ]) 39 | ->setFinder($finder); -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to `valuestore` will be documented in this file 4 | 5 | ## 1.3.3 - 2025-02-14 6 | 7 | ### What's Changed 8 | 9 | * Laravel 12.x Compatibility by @laravel-shift in https://github.com/spatie/valuestore/pull/49 10 | 11 | ### New Contributors 12 | 13 | * @laravel-shift made their first contribution in https://github.com/spatie/valuestore/pull/49 14 | 15 | **Full Changelog**: https://github.com/spatie/valuestore/compare/1.3.2...1.3.3 16 | 17 | ## 1.3.2 - 2022-12-13 18 | 19 | ### What's Changed 20 | 21 | - Add PHP 8.2 Support by @patinthehat in https://github.com/spatie/valuestore/pull/44 22 | - Feature/cleanup for 8 by @kudashevs in https://github.com/spatie/valuestore/pull/45 23 | 24 | ### New Contributors 25 | 26 | - @patinthehat made their first contribution in https://github.com/spatie/valuestore/pull/44 27 | - @kudashevs made their first contribution in https://github.com/spatie/valuestore/pull/45 28 | 29 | **Full Changelog**: https://github.com/spatie/valuestore/compare/1.3.1...1.3.2 30 | 31 | ## 1.3.1 - 2021-12-03 32 | 33 | - improve support for PHP 8.1 34 | 35 | ## 1.3.0 - 2021-11-18 36 | 37 | - Add support for PHP 8.1 38 | 39 | **Full Changelog**: https://github.com/spatie/valuestore/compare/1.2.5...1.3.0 40 | 41 | ## 1.2.5 - 2020-11-30 42 | 43 | - add support for PHP 8 44 | 45 | ## 1.2.4 - 2020-08-23 46 | 47 | - `all` will now always return an array (#23) 48 | 49 | ## 1.2.3 - 2019-02-15 50 | 51 | - update deps 52 | 53 | ## 1.2.2 - 2018-05-15 54 | 55 | - small performance improvement 56 | 57 | ## 1.2.1 - 2017-10-10 58 | 59 | - avoid writing to the json file when putting an empty array 60 | 61 | ## 1.2.0 - 2017-09-29 62 | 63 | - add second parameter to `make` 64 | 65 | ## 1.1.0 - 2017-01-20 66 | 67 | - add `prepend` method 68 | 69 | ## 1.0.0 - 2016-04-06 70 | 71 | - initial release 72 | -------------------------------------------------------------------------------- /src/Valuestore.php: -------------------------------------------------------------------------------- 1 | setFileName($fileName); 15 | 16 | if (! is_null($values)) { 17 | $valuestore->put($values); 18 | } 19 | 20 | return $valuestore; 21 | } 22 | 23 | protected function __construct() 24 | { 25 | } 26 | 27 | protected function setFileName(string $fileName): static 28 | { 29 | $this->fileName = $fileName; 30 | 31 | return $this; 32 | } 33 | 34 | public function put( 35 | array|string $name, 36 | mixed $value = null 37 | ): static { 38 | if ($name === []) { 39 | return $this; 40 | } 41 | 42 | $newValues = $name; 43 | 44 | if (! is_array($name)) { 45 | $newValues = [$name => $value]; 46 | } 47 | 48 | $newContent = array_merge($this->all(), $newValues); 49 | 50 | $this->setContent($newContent); 51 | 52 | return $this; 53 | } 54 | 55 | public function push(string $name, mixed $pushValue): static 56 | { 57 | if (! is_array($pushValue)) { 58 | $pushValue = [$pushValue]; 59 | } 60 | 61 | if (! $this->has($name)) { 62 | $this->put($name, $pushValue); 63 | 64 | return $this; 65 | } 66 | 67 | $oldValue = $this->get($name); 68 | 69 | if (! is_array($oldValue)) { 70 | $oldValue = [$oldValue]; 71 | } 72 | 73 | $newValue = array_merge($oldValue, $pushValue); 74 | 75 | $this->put($name, $newValue); 76 | 77 | return $this; 78 | } 79 | 80 | public function prepend(string $name, mixed $prependValue): static 81 | { 82 | if (! is_array($prependValue)) { 83 | $prependValue = [$prependValue]; 84 | } 85 | 86 | if (! $this->has($name)) { 87 | $this->put($name, $prependValue); 88 | 89 | return $this; 90 | } 91 | 92 | $oldValue = $this->get($name); 93 | 94 | if (! is_array($oldValue)) { 95 | $oldValue = [$oldValue]; 96 | } 97 | 98 | $newValue = array_merge($prependValue, $oldValue); 99 | 100 | $this->put($name, $newValue); 101 | 102 | return $this; 103 | } 104 | 105 | public function get(string $name, mixed $default = null): mixed 106 | { 107 | $all = $this->all(); 108 | 109 | if (! array_key_exists($name, $all)) { 110 | return $default; 111 | } 112 | 113 | return $all[$name]; 114 | } 115 | 116 | public function has(string $name): bool 117 | { 118 | return array_key_exists($name, $this->all()); 119 | } 120 | 121 | public function all(): array 122 | { 123 | if (! file_exists($this->fileName)) { 124 | return []; 125 | } 126 | 127 | return json_decode(file_get_contents($this->fileName), true) ?? []; 128 | } 129 | 130 | public function allStartingWith(string $startingWith = ''): array 131 | { 132 | $values = $this->all(); 133 | 134 | if ($startingWith === '') { 135 | return $values; 136 | } 137 | 138 | return $this->filterKeysStartingWith($values, $startingWith); 139 | } 140 | 141 | public function forget(string $key): static 142 | { 143 | $newContent = $this->all(); 144 | 145 | unset($newContent[$key]); 146 | 147 | $this->setContent($newContent); 148 | 149 | return $this; 150 | } 151 | 152 | public function flush(): static 153 | { 154 | return $this->setContent([]); 155 | } 156 | 157 | public function flushStartingWith(string $startingWith = ''): static 158 | { 159 | $newContent = []; 160 | 161 | if ($startingWith !== '') { 162 | $newContent = $this->filterKeysNotStartingWith($this->all(), $startingWith); 163 | } 164 | 165 | return $this->setContent($newContent); 166 | } 167 | 168 | public function pull(string $name): mixed 169 | { 170 | $value = $this->get($name); 171 | 172 | $this->forget($name); 173 | 174 | return $value; 175 | } 176 | 177 | public function increment(string $name, int $by = 1): mixed 178 | { 179 | $currentValue = $this->get($name) ?? 0; 180 | 181 | if (! $this->isNumber($currentValue)) { 182 | return $currentValue; 183 | } 184 | 185 | $newValue = $currentValue + $by; 186 | 187 | $this->put($name, $newValue); 188 | 189 | return $newValue; 190 | } 191 | 192 | public function decrement(string $name, int $by = 1): array|string|int|float|null 193 | { 194 | return $this->increment($name, $by * -1); 195 | } 196 | 197 | public function offsetExists($offset): bool 198 | { 199 | return $this->has($offset); 200 | } 201 | 202 | public function offsetGet($offset): mixed 203 | { 204 | return $this->get($offset); 205 | } 206 | 207 | public function offsetSet($offset, $value): void 208 | { 209 | $this->put($offset, $value); 210 | } 211 | 212 | public function offsetUnset($offset): void 213 | { 214 | $this->forget($offset); 215 | } 216 | 217 | public function count(): int 218 | { 219 | return count($this->all()); 220 | } 221 | 222 | protected function filterKeysStartingWith(array $values, string $startsWith): array 223 | { 224 | return array_filter($values, function ($key) use ($startsWith) { 225 | return str_starts_with($key, $startsWith); 226 | }, ARRAY_FILTER_USE_KEY); 227 | } 228 | 229 | protected function filterKeysNotStartingWith(array $values, string $startsWith): array 230 | { 231 | return array_filter($values, function ($key) use ($startsWith) { 232 | return ! str_starts_with($key, $startsWith); 233 | }, ARRAY_FILTER_USE_KEY); 234 | } 235 | 236 | protected function setContent(array $values): static 237 | { 238 | file_put_contents($this->fileName, json_encode($values)); 239 | 240 | if (! count($values)) { 241 | unlink($this->fileName); 242 | } 243 | 244 | return $this; 245 | } 246 | 247 | protected function isNumber($value): bool 248 | { 249 | return is_int($value) || is_float($value); 250 | } 251 | } 252 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Easily store some loose values 2 | 3 | [![Latest Version on Packagist](https://img.shields.io/packagist/v/spatie/valuestore.svg?style=flat-square)](https://packagist.org/packages/spatie/valuestore) 4 | [![Software License](https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square)](LICENSE.md) 5 | ![Tests](https://github.com/spatie/valuestore/workflows/Tests/badge.svg) 6 | [![Total Downloads](https://img.shields.io/packagist/dt/spatie/valuestore.svg?style=flat-square)](https://packagist.org/packages/spatie/valuestore) 7 | 8 | This package makes it easy to store and retrieve some loose values. Stored values are saved as a json file. 9 | 10 | It can be used like this: 11 | 12 | ```php 13 | use Spatie\Valuestore\Valuestore; 14 | 15 | $valuestore = Valuestore::make($pathToFile); 16 | 17 | $valuestore->put('key', 'value'); 18 | 19 | $valuestore->get('key'); // Returns 'value' 20 | 21 | $valuestore->has('key'); // Returns true 22 | 23 | // Specify a default value for when the specified key does not exist 24 | $valuestore->get('non existing key', 'default') // Returns 'default' 25 | 26 | $valuestore->put('anotherKey', 'anotherValue'); 27 | 28 | // Put multiple items in one go 29 | $valuestore->put(['ringo' => 'drums', 'paul' => 'bass']); 30 | 31 | $valuestore->all(); // Returns an array with all items 32 | 33 | $valuestore->forget('key'); // Removes the item 34 | 35 | $valuestore->flush(); // Empty the entire valuestore 36 | 37 | $valuestore->flushStartingWith('somekey'); // remove all items whose keys start with "somekey" 38 | 39 | $valuestore->increment('number'); // $valuestore->get('number') will return 1 40 | $valuestore->increment('number'); // $valuestore->get('number') will return 2 41 | $valuestore->increment('number', 3); // $valuestore->get('number') will return 5 42 | 43 | // Valuestore implements ArrayAccess 44 | $valuestore['key'] = 'value'; 45 | $valuestore['key']; // Returns 'value' 46 | isset($valuestore['key']); // Return true 47 | unset($valuestore['key']); // Equivalent to removing the value 48 | 49 | // Valuestore implements Countable 50 | count($valuestore); // Returns 0 51 | $valuestore->put('key', 'value'); 52 | count($valuestore); // Returns 1 53 | ``` 54 | 55 | Read the [usage](#usage) section of this readme to learn about the other methods. 56 | 57 | In [this post on Laravel News](https://laravel-news.com/global-application-settings), [Tim MacDonald](https://twitter.com/timacdonald87) shares how you can use this package to power a `settings` function. 58 | 59 | Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource). 60 | 61 | ## Support us 62 | 63 | [](https://spatie.be/github-ad-click/valuestore) 64 | 65 | We invest a lot of resources into creating [best in class open source packages](https://spatie.be/open-source). You can support us by [buying one of our paid products](https://spatie.be/open-source/support-us). 66 | 67 | We highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. You'll find our address on [our contact page](https://spatie.be/about-us). We publish all received postcards on [our virtual postcard wall](https://spatie.be/open-source/postcards). 68 | 69 | ## Installation 70 | 71 | You can install the package via composer: 72 | 73 | ``` bash 74 | composer require spatie/valuestore 75 | ``` 76 | 77 | ## Usage 78 | 79 | To create a Valuestore use the `make` method. 80 | 81 | ```php 82 | $valuestore = Valuestore::make($pathToFile); 83 | ``` 84 | 85 | You can also pass some values as a second argument. These will be added to the valuestore using the `put` method. 86 | 87 | ```php 88 | $valuestore = Valuestore::make($pathToFile, ['key' => 'value']); 89 | ``` 90 | 91 | All values will be saved as json in the given file. 92 | 93 | When there are no values stored, the file will be deleted. 94 | 95 | You can call the following methods on the `Valuestore` 96 | 97 | ### put 98 | ```php 99 | /** 100 | * Put a value in the store. 101 | * 102 | * @param string|array $name 103 | * @param string|int|null $value 104 | * 105 | * @return $this 106 | */ 107 | public function put($name, $value = null) 108 | ``` 109 | 110 | ### get 111 | 112 | ```php 113 | /** 114 | * Get a value from the store. 115 | * 116 | * @param string $name 117 | * 118 | * @return null|string 119 | */ 120 | public function get(string $name) 121 | ``` 122 | 123 | ### has 124 | 125 | ```php 126 | /* 127 | * Determine if the store has a value for the given name. 128 | */ 129 | public function has(string $name) : bool 130 | ``` 131 | 132 | ### all 133 | ```php 134 | /** 135 | * Get all values from the store. 136 | * 137 | * @return array 138 | */ 139 | public function all() : array 140 | ``` 141 | 142 | ### allStartingWith 143 | ```php 144 | /** 145 | * Get all values from the store which keys start with the given string. 146 | * 147 | * @param string $startingWith 148 | * 149 | * @return array 150 | */ 151 | public function allStartingWith(string $startingWith = '') : array 152 | ``` 153 | 154 | ### forget 155 | ```php 156 | /** 157 | * Forget a value from the store. 158 | * 159 | * @param string $key 160 | * 161 | * @return $this 162 | */ 163 | public function forget(string $key) 164 | ``` 165 | 166 | ### flush 167 | ```php 168 | /** 169 | * Flush all values from the store. 170 | * 171 | * @return $this 172 | */ 173 | public function flush() 174 | ``` 175 | 176 | ### flushStartingWith 177 | ```php 178 | /** 179 | * Flush all values from the store which keys start with the specified value. 180 | * 181 | * @param string $startingWith 182 | * 183 | * @return $this 184 | */ 185 | public function flushStartingWith(string $startingWith) 186 | ``` 187 | 188 | ### pull 189 | ```php 190 | /** 191 | * Get and forget a value from the store. 192 | * 193 | * @param string $name 194 | * 195 | * @return null|string 196 | */ 197 | public function pull(string $name) 198 | ``` 199 | 200 | ### increment 201 | ```php 202 | /** 203 | * Increment a value from the store. 204 | * 205 | * @param string $name 206 | * @param int $by 207 | * 208 | * @return int|null|string 209 | */ 210 | public function increment(string $name, int $by = 1) 211 | ``` 212 | 213 | ### decrement 214 | ```php 215 | /** 216 | * Decrement a value from the store. 217 | * 218 | * @param string $name 219 | * @param int $by 220 | * 221 | * @return int|null|string 222 | */ 223 | public function decrement(string $name, int $by = 1) 224 | ``` 225 | 226 | ## push 227 | ```php 228 | /** 229 | * Push a new value into an array. 230 | * 231 | * @param string $name 232 | * @param $pushValue 233 | * 234 | * @return $this 235 | */ 236 | public function push(string $name, $pushValue) 237 | ``` 238 | 239 | ## prepend 240 | ```php 241 | /** 242 | * Prepend a new value into an array. 243 | * 244 | * @param string $name 245 | * @param $prependValue 246 | * 247 | * @return $this 248 | */ 249 | public function prepend(string $name, $prependValue) 250 | ``` 251 | 252 | ## count 253 | ```php 254 | /** 255 | * Count elements. 256 | * 257 | * @return int 258 | */ 259 | public function count() 260 | ``` 261 | 262 | ## Changelog 263 | 264 | Please see [CHANGELOG](CHANGELOG.md) for more information about what has changed recently. 265 | 266 | ## Testing 267 | 268 | ``` bash 269 | $ composer test 270 | ``` 271 | 272 | ## Contributing 273 | 274 | Please see [CONTRIBUTING](https://github.com/spatie/.github/blob/main/CONTRIBUTING.md) for details. 275 | 276 | ## Security 277 | 278 | If you've found a bug regarding security please mail [security@spatie.be](mailto:security@spatie.be) instead of using the issue tracker. 279 | 280 | ## Postcardware 281 | 282 | You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using. 283 | 284 | Our address is: Spatie, Kruikstraat 22, 2018 Antwerp, Belgium. 285 | 286 | We publish all received postcards [on our company website](https://spatie.be/en/opensource/postcards). 287 | 288 | ## Credits 289 | 290 | - [Freek Van der Herten](https://github.com/freekmurze) 291 | - [Jolita Grazyte](https://github.com/JolitaGrazyte) 292 | - [All Contributors](../../contributors) 293 | 294 | ## License 295 | 296 | The MIT License (MIT). Please see [License File](LICENSE.md) for more information. 297 | --------------------------------------------------------------------------------