Download the PHP package sassnowski/option without Composer

On this page you can find all versions of the php package sassnowski/option. 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 option

Option Type for PHP

Build Status Coverage Status Code Climate SensioLabsInsight

A PHP implementation of the Option data type from Scala (or Maybe from Haskell if you want).

DISCLAIMER: This package is not intented to be used in production. Its intend was to serve as a coding exercise to myself about how I would implement and Option Type in PHP. If you want to use this in production I'd recommend you use https://github.com/schmittjoh/php-option instead.

Installation

Install the package through composer:

That’s it! Now you can use it in your code.

Summary

An Option represents an optional value, or in other words a value that may not exist. It is sometimes described as a List that contains a maximum of one item.

An Option is used in places where otherwise null might be used, e.g., the result of a Database Query. A more general way to put it is: A computation might return an Option if it is not defined for some inputs.

Option::map($func)

Using Options means that a lot of code needs to be aware of this data type. In order to still be able to reuse functions that operate on unwrapped values, this class provides a map function.

The purpose of the map function is to lift a function that normally operators on regular values to now work on Option values. Formally it turns a function of type

into a function of type

Example

The above example lifted the function length of type string -> int into a function of type Option string -> Option int. This means that we can still write and use functions that were written without optional values in mind and simply lift them to a function that can handle Options.

An important characteristic of the map method is, that the function that is being mapped over the option will never get executed if we’re dealing with an undefined value.

Option::flatMap($func)

Todo

Option::getOrElse($default)

Todo

Option::orElse($alternative)

Todo

Option::isDefined()

This function simply returns true if the value is anything other than null in which case it returns false.

License

MIT


All versions of option with dependencies

PHP Build Version
Package Version
Requires php Version >=5.5
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 sassnowski/option contains the following files

Loading the files please wait ....