Download the PHP package cocur/vale without Composer

On this page you can find all versions of the php package cocur/vale. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package vale

Vale

Vale helps you working with complex data structures. Easily get, set, unset and check the existence of values in deeply nested arrays and objects.

Build Status Windows Build status Scrutinizer Code Quality Code Coverage StyleCI

Developed by Florian Eckerstorfer in Vienna, Europe.

Features

Installation

You can install Vale using Composer:

Usage

You can use either the static methods provided by Vale or create an instance of Vale.

For flat arrays and objects (that is, arrays and objects with only one level of depth) you can also use a string or integer as key. This works for the static as well as the instance methods.

Get

::get() and ->getValue() return the value of a specified element.

Returns the element at the given position or the original $data if $keys is empty.

Vale tries different ways to access the element specified in $keys. The following variants are tried in this order:

  1. $data[$key]
  2. $data->$key()
  3. $data->get$Key()
  4. $data->get($key)
  5. $data->has$Key()
  6. $data->has($key)
  7. $data->is$Key()
  8. $data->is($key)
  9. $data->$key

Set

::set() and ->setValue() set the value of an element at the given position.

Returns the modified $data

Set utilizes the same means of navigating through nested data structures as Get and tries the following variants to set the value:

  1. $data[$key] = $value
  2. $data->$key($value)
  3. $data->set$Key($value)
  4. $data->set($key, $value)
  5. $data->$key = $value

Has

::has() and ->hasValue() returns if an element exists

Returns true if the element exists, false otherwise.

Has utilizes the same means of navigating through nested data structures as Get and tries the following variants to check the existence of an element:

  1. isset($data[$key])
  2. isset($data->$key)
  3. $data->has$Key()
  4. $data->has($key)
  5. $data->is$Key()
  6. $data->is($key)
  7. $data->$key()
  8. $data->get$Key()

The variants involving a method call (such as has$Key() or has()) return true if the method returns true or a value that evaluates to true. If the method returns a value that evaluates to false (such as '', 0 or null) then has returns false.

Remove

::remove() and ->removeValue() remove an element from the given data structure

Returns the modified $data or null if $keys is empty

Remove utilizes the same means of navigating through nested data structures as Get and tries the following variants to remove the element from the data structure:

  1. unset($data[$key])
  2. unset($data->$key)
  3. $data->unset$Key()
  4. $data->remove$Key()
  5. $data->remove($key)

Please note that unset() is not used, because it is an reserved keyword in PHP.

Change Log

Version 0.2 (24 March 2015)

Version 0.1 (15 March 2015)

Motivation

Vale was largely motivated by the need for a simpler, but faster implementation of the Symfony PropertyAccess component. PropertyAccess is great when used in templates or config files, that is, code that is compiled and cached before being executed. However, the heavy use of string parsing and reflection make PropertyAccess not suitable for code that is not compiled. Another source of inspiration was the get-in library by Igor Wiedler for array traversal.

Name: I used A Song of Ice and Fire related strings for testing and due to having to write value quite often, I came up with Vale.

Author

Vale has been developed by Florian Eckerstorfer (Twitter) in Vienna, Europe.

Vale is a project of Cocur. You can contact us on Twitter: @cocurco

License

The MIT license applies to Vale. For the full copyright and license information, please view the LICENSE file distributed with this source code.


All versions of vale with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package cocur/vale contains the following files

Loading the files please wait ....