PHP Classes
elePHPant
Icontem

PHP Primitive Types Class: Manipulate PHP primitive value types as objects

Recommend this page to a friend!
  Info   View files Documentation   View files View files (144)   DownloadInstall with Composer Download .zip   Reputation   Support forum   Blog    
Last Updated Ratings Unique User Downloads Download Rankings
2019-05-04 (2 months ago) RSS 2.0 feedNot yet rated by the usersTotal: 46 All time: 9,556 This week: 365Up
Version License PHP version Categories
php-prim 1.0.0MIT/X Consortium ...7.3Utilities and Tools, Text processing, D..., P..., T...
Description Author

This package can manipulate PHP primitive value types as objects.

It provides several classes that encapsulate the behavior of several types of data types like strings, booleans, integers, and floats.

The objects of these classes are immutable, so applications cannot change them after they are created.

  Performance   Level  

Details

<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:

    `php 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]._

    `php use NorseBlue\Prim\Facades\Scalar\StringFacade as Str;

    echo Str::upper('my string');

    // Outputs: // MY STRING `

  3. Using the namespaced functions:

    `php 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

  Files folder image Files  
File Role Description
Files folder image.assets (2 files)
Files folder image.changelog (3 files)
Files folder image.circleci (1 file)
Files folder image.github (4 files)
Files folder imagesrc (4 files, 7 directories)
Files folder imagetests (1 file, 3 directories)
Accessible without login Plain text file .editorconfig Data Auxiliary data
Accessible without login Plain text file .phpcs.xml.dist Data Auxiliary data
Accessible without login Plain text file .styleci.yml Data Auxiliary data
Accessible without login Plain text file CHANGELOG.md Data Auxiliary data
Accessible without login Plain text file composer.json Data Auxiliary data
Accessible without login Plain text file LICENSE.md Lic. License text
Accessible without login Plain text file phpstan.neon.dist Data Auxiliary data
Accessible without login Plain text file phpunit.xml.dist Data Auxiliary data
Accessible without login Plain text file prim.sublime-project Data Auxiliary data
Accessible without login Plain text file README.md Doc. Documentation

 Version Control Unique User Downloads Download Rankings  
 100%
Total:46
This week:0
All time:9,556
This week:365Up