PHPackages                             chevere/var-support - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. chevere/var-support

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

chevere/var-support
===================

A chevere var-support package

1.0.2(3mo ago)120.5k↓64.6%[1 issues](https://github.com/chevere/var-support/issues)3Apache-2.0PHPPHP ^8.1CI passing

Since Nov 30Pushed 3mo agoCompare

[ Source](https://github.com/chevere/var-support)[ Packagist](https://packagist.org/packages/chevere/var-support)[ Docs](https://chevere.org)[ RSS](/packages/chevere-var-support/feed)WikiDiscussions 1.0 Synced 2d ago

READMEChangelog (3)Dependencies (10)Versions (4)Used By (3)

VarSupport
==========

[](#varsupport)

[![Chevere](chevere.svg)](chevere.svg)

[![Build](https://camo.githubusercontent.com/cfb0e0f4624d8362b57a09e594e7e995da204e38f46162d713d97c9c9a01e4bf/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636865766572652f7661722d737570706f72742f746573742e796d6c3f6272616e63683d312e30267374796c653d666c61742d737175617265)](https://github.com/chevere/var-support/actions)[![Code size](https://camo.githubusercontent.com/dfed98a931ee00716a3ae557e612f2e8098c952efa1d881df7f3ea1237f4ea5e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f7661722d737570706f72743f7374796c653d666c61742d737175617265)](https://camo.githubusercontent.com/dfed98a931ee00716a3ae557e612f2e8098c952efa1d881df7f3ea1237f4ea5e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c616e6775616765732f636f64652d73697a652f636865766572652f7661722d737570706f72743f7374796c653d666c61742d737175617265)[![Apache-2.0](https://camo.githubusercontent.com/766d8589bbfac0b52c3157273b4ecfc36b66c56ac5969216592f6fee11c6323b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f636865766572652f7661722d737570706f72743f7374796c653d666c61742d737175617265)](LICENSE)[![PHPStan](https://camo.githubusercontent.com/6016298b28550819030c76e9327f62501596a31fd76406695bae2f3d2a1f26a4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c253230392d626c756576696f6c65743f7374796c653d666c61742d737175617265)](https://phpstan.org/)[![Mutation testing badge](https://camo.githubusercontent.com/ba4706a77d4bacc90108942a80f8c7d3c96b165e115db65a51a0e1be60d30469/68747470733a2f2f696d672e736869656c64732e696f2f656e64706f696e743f7374796c653d666c61742d7371756172652675726c3d687474707325334125324625324662616467652d6170692e737472796b65722d6d757461746f722e696f2532466769746875622e636f6d253246636865766572652532467661722d737570706f7274253246312e30)](https://dashboard.stryker-mutator.io/reports/github.com/chevere/var-support/1.0)

[![Quality Gate Status](https://camo.githubusercontent.com/7b8dc30656ba3fef772e707830c7f1fa6a0cbe0a71926d4f8ce6e7b7c6b3f871/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d616c6572745f737461747573)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![Maintainability Rating](https://camo.githubusercontent.com/e6691bb1ce942f9e349c4db6011de722bd0c39633bfeef85a2f6be081bab2c78/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d7371616c655f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![Reliability Rating](https://camo.githubusercontent.com/2bb674ceaecec00ba4932f17e27d542f940667dc329b215048083c0591006c8c/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d72656c696162696c6974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![Security Rating](https://camo.githubusercontent.com/4b404aea2d231dbe9031a4da34a457351d2f1dd4e1f8081fb43aaf38f6096f6f/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d73656375726974795f726174696e67)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![Coverage](https://camo.githubusercontent.com/16a71f51bb346cafb938469a97aeeacd6944b1fdcc9281a1cee34040e5fe5497/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d636f766572616765)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![Technical Debt](https://camo.githubusercontent.com/c56ee25a0c61fae0e2b6ac415ac24b7a1a1c9991f6d2f64b5863376dd8d90695/68747470733a2f2f736f6e6172636c6f75642e696f2f6170692f70726f6a6563745f6261646765732f6d6561737572653f70726f6a6563743d636865766572655f7661722d737570706f7274266d65747269633d7371616c655f696e646578)](https://sonarcloud.io/dashboard?id=chevere_var-support)[![CodeFactor](https://camo.githubusercontent.com/7a05bf235c67da55224b391f5bef3baf188d48e9ce2272118e4eafba0854ff1f/68747470733a2f2f7777772e636f6465666163746f722e696f2f7265706f7369746f72792f6769746875622f636865766572652f7661722d737570706f72742f6261646765)](https://www.codefactor.io/repository/github/chevere/var-support)

Summary
-------

[](#summary)

Extra tools for handling variables.

Installing
----------

[](#installing)

VarSupport is available through [Packagist](https://packagist.org/packages/chevere/var-support) and the repository source is at [chevere/var-support](https://github.com/chevere/var-support).

```
composer require chevere/var-support
```

ObjectVariable
--------------

[](#objectvariable)

The `ObjectVariable` component is in charge of handling an object variable.

### Creating ObjectVariable

[](#creating-objectvariable)

```
use Chevere\VarSupport\ObjectVariable;

$object = new ObjectVariable($var);
$var = $object->variable();
```

### Assert clonable

[](#assert-clonable)

Use `assertClonable` to assert if the object variable can be cloned.

```
$boolean = $object->assertClonable();
```

StorableVariable
----------------

[](#storablevariable)

The `StorableVariable` component is in charge of handling a variable that can be stored (state).

A storable variable for Chevere is any PHP variable that can be stored as a string representation. All variable types can be stored with the exception of type `resource`.

### Creating StorableVariable

[](#creating-storablevariable)

```
use Chevere\VarSupport\StorableVariable;

$storable = new StorableVariable($var);
$var = $storable->variable();
```

### Export

[](#export)

The `toExport` method exports the variable, this return value should be used when creating a file return.

```
$export = $storable->toExport();
file_put_contents(
    'file-return.php',
    '
