PHP Classes

File: README.md

Recommend this page to a friend!
  Packages of Axel Pardemann   PHP Primitive Types Class   README.md   Download  
File: README.md
Role: Documentation
Content type: text/markdown
Description: Documentation
Class: PHP Primitive Types Class
Manipulate PHP primitive value types as objects
Author: By
Last change: Add optional package to README deprecation notice

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
Add deprecation notice to README

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
Reword some text in README

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
Update README file

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
Add subtitle to README name

# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
# If applied, this commit will...


# Explain why this change is being made

# Provide links to any relevant tickets, articles or other resources
Date: 8 months ago
Size: 4,890 bytes
 

Contents

Class file image Download

<div align="center"> <h1>PHP Primitive Objects</h1> <p align="center">

<a href="https://circleci.com/gh/norse-blue/php-prim/tree/master"><img alt="Build Status" src="https://img.shields.io/circleci/project/github/norse-blue/php-prim/master.svg?color=%23a3be8c&style=popout-square"></a>
<a href="https://php.net/releases"><img alt="PHP Version" src="https://img.shields.io/packagist/php-v/norse-blue/prim.svg?color=%23b48ead&style=popout-square"></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="Stable Release" src="https://img.shields.io/packagist/v/norse-blue/prim.svg?color=%235e81ac&style=popout-square"></a>
<a href="https://codeclimate.com/github/norse-blue/php-prim/maintainability"><img src="https://api.codeclimate.com/v1/badges/51195ec3a47a8b071381/maintainability" /></a>
<a href="https://codeclimate.com/github/norse-blue/php-prim/test_coverage"><img src="https://api.codeclimate.com/v1/badges/51195ec3a47a8b071381/test_coverage" /></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="Total Downloads" src="https://img.shields.io/packagist/dt/norse-blue/prim.svg?color=%235e81ac&style=popout-square"></a>
<a href="https://packagist.org/packages/norse-blue/prim"><img alt="GitHub" src="https://img.shields.io/github/license/norse-blue/php-prim.svg?color=%235e81ac&style=popout-square"></a>

</p> </div> <hr>

DEPRECATED: This package was growing too big and has now been deprecated in favor of the following smaller, segmented and more contained packages: - norse-blue/collection-objects - norse-blue/enum-objects - norse-blue/extensible-objects - norse-blue/handy-properties - norse-blue/optionals - norse-blue/scalar-objects - norse-blue/value-objects

PHP Prim is a PHP library that exposes primitive types as immutable objects with convenience methods to operate on them.

Installation

>Requirements: >- PHP 7.3+ >- BC Math extension (for UUIDs) >- JSON extension >- Multibyte String extension

Install Prim using Composer:

composer require norse-blue/prim

Usage

There are three ways to create a primitive object instance:

  1. Using the `new` keyword:

    use NorseBlue\Prim\Scalars\StringObject as Str;
    
    $str = new Str('my string');
    echo $str->upper();
    
    // Outputs:
    // MY STRING
    
  2. Using the facades:

    _Note: params passed by reference are not supported in facades because the calls depend on `__callStatic`, which does not pass params by reference. See [Overloading][php_overloading_url]._

    use NorseBlue\Prim\Facades\Scalar\StringFacade as Str;
    
    echo Str::upper('my string');
    
    // Outputs:
    // MY STRING
    
  3. Using the namespaced functions:

    use NorseBlue\Prim\string;
    
    $str = string('my string');
    echo $str->upper();
    
    // Outputs:
    // MY STRING
    

You can also chain methods together:

use NorseBlue\Prim\string;

$str = string('THIS IS MY TEXT.')->lower()->ucfirst();
echo $str;

// Outputs:
// This is my text.

You don't need to worry about side-effects for scalar objects, as they are implemented as immutable objects and each method returns a new object. To store the value don't forget to assign it to a variable or it will be lost.

Documentation

For the full documentation refer to the docs folder.

Changelog

Please refer to the CHANGELOG.md file for more information about what has changed recently.

Contributing

Contributions to this project are accepted and encouraged. Please read the CONTRIBUTING.md file for details on contributions.

Credits

Security

If you discover any security related issues, please email security@norse.blue instead of using the issue tracker.

Support the development

Do you like this project? Support it by donating

<a href="https://www.buymeacoffee.com/axelitus">

<img src=".assets/buy-me-a-coffee.svg" width="180" alt="Buy me a coffee" />

</a>

License

PHP Prim is open-sourced software licensed under the MIT license.

[php_overloading_url]: https://www.php.net/manual/en/language.oop5.overloading.php