Home
Docs
GitHub
Pricing
Blog
Log In

Run Sandworm Audit for your App

Get started
Generated on May 24, 2024 via composer

phpoption/phpoption 1.9.1

Option Type for PHP
Package summary
Share
0
issues
1
license
1
Apache-2.0
Package created
5 Nov 2012
Version published
25 Feb 2023
Maintainers
1
Total deps
1
Direct deps
0
License
Apache-2.0

Issues

0
This package has no issues

Licenses

Apache License 2.0

Permissive
OSI Approved
This is a human-readable summary of (and not a substitute for) the license. Disclaimer.
Can
commercial-use
modify
distribute
sublicense
private-use
use-patent-claims
place-warranty
Cannot
hold-liable
use-trademark
Must
include-copyright
include-license
state-changes
include-notice
1 Packages, Including:
phpoption/phpoption@1.9.1
Disclaimer

This deed highlights only some of the key features and terms of the actual license. It is not a license and has no legal value. You should carefully review all of the terms and conditions of the actual license before using the licensed material.

Sandworm is not a law firm and does not provide legal services. Distributing, displaying, or linking to this deed or the license that it summarizes does not create a lawyer-client or any other relationship.

Direct Dependencies

0
All Dependencies CSV
β“˜ This is a list of phpoption/phpoption 's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.
NameVersionSizeLicenseTypeVulnerabilities

Visualizations

Frequently Asked Questions

What does phpoption/phpoption do?

The phpoption/phpoption is a package that implements the Option type for PHP programming language. Its primary function is to handle cases where a return type might vary based on certain conditions or runtime factors. It helps prevent accidental omissions in code handling by forcing a developer to consider all possible return cases. This improves code robustness and facilitates a more concise and empowered API development and usage.

How do you use phpoption/phpoption?

The phpoption/phpoption can be employed in your PHP applications through a straightforward installation and usage process. To install, you can add it directly to your project using Composer, either by requiring it in your terminal:

$ composer require phpoption/phpoption

Or by manually adding it to your composer.json file.

Usage of phpoption/phpoption package involves creating a new Option, either a Some or None instance, based on whether an entity could be found or not.

To create a new Option:

class MyRepository
{
    public function findSomeEntity($criteria): \PhpOption\Option
    {
        if (null !== $entity = $this->em->find(...)) {
            return new \PhpOption\Some($entity);
        }

        // We use a singleton, for the None case.
        return \PhpOption\None::create();
    }
}

You can use a shorter version, considering null as None and everything else as Some case:

class MyRepository
{
    public function findSomeEntity($criteria): \PhpOption\Option
    {
        return \PhpOption\Option::fromValue($this->em->find(...));

        // or, if you want to change the none value to false for example:
        return \PhpOption\Option::fromValue($this->em->find(...), false);
    }
}

Where are the phpoption/phpoption docs?

The primary documentation for the phpoption/phpoption package is available directly within its GitHub repository. Extensive code examples and explanations are provided directly in the README file for you to understand the concepts and usage of the package. Additional resources regarding security, license and enterprise subscription can also be found there.