PHP Classes

File: README.md

Recommend this page to a friend!
  Classes 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:
Date: 3 years ago
Size: 4,116 bytes
 

Contents

Class file image Download

<div align="center"> <img src=".assets/prim-logo.png"> <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>

PHP Prim is a PHP library that exposes primitive object data types for your convenience.

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 data type 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, as the objects are immutable and each function returns a new immutable object, so to store the value don't forget to assign it to a variable.

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

For more information send a message to info at phpclasses dot org.