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 (18 days ago) RSS 2.0 feedNot yet rated by the usersTotal: 43 This week: 8All time: 9,523 This week: 51Up
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  
Name: Axel Pardemann <contact>
Classes: 3 packages by
Country: Mexico Mexico
Age: 36
All time rank: 207321 in Mexico Mexico
Week rank: 42 Up1 in Mexico Mexico Up

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

  Files folder image Files  /  .assets  
File Role Description
  Accessible without login Plain text file buy-me-a-coffee.svg Data Auxiliary data
  Accessible without login Image file prim-logo.png Icon Icon image

  Files folder image Files  /  .changelog  
File Role Description
  Accessible without login Plain text file CURRENT.md Data Auxiliary data
  Accessible without login Plain text file ROADMAP.md Data Auxiliary data
  Accessible without login Plain text file UNRELEASED.md Data Auxiliary data

  Files folder image Files  /  .circleci  
File Role Description
  Accessible without login Plain text file config.yml Data Auxiliary data

  Files folder image Files  /  .github  
File Role Description
  Accessible without login Plain text file CODE_OF_CONDUCT.md Data Auxiliary data
  Accessible without login Plain text file CONTRIBUTING.md Data Auxiliary data
  Accessible without login Plain text file ISSUE_TEMPLATE.md Data Auxiliary data
  Accessible without login Plain text file PULL_REQUEST_TEMPLATE.md Data Auxiliary data

  Files folder image Files  /  src  
File Role Description
Files folder imageCollections (1 file)
Files folder imageContracts (2 files)
Files folder imageExceptions (4 files, 1 directory)
Files folder imageFacades (1 file, 1 directory)
Files folder imageScalars (4 files, 1 directory)
Files folder imageSupport (1 file)
Files folder imageTraits (2 files)
  Plain text file ImmutableValueObject.php Class Class source
  Plain text file register_extensions.php Class Class source
  Accessible without login Plain text file scalar_functions.php Example Example script
  Plain text file ValueObject.php Class Class source

  Files folder image Files  /  src  /  Collections  
File Role Description
  Plain text file DotArray.php Class Class source

  Files folder image Files  /  src  /  Contracts  
File Role Description
  Plain text file DotArrayAccess.php Class Class source
  Plain text file ValueObject.php Class Class source

  Files folder image Files  /  src  /  Exceptions  
File Role Description
Files folder imageScalars (1 directory)
  Plain text file ImmutableValueException.php Class Class source
  Plain text file InvalidFacadeClassException.php Class Class source
  Plain text file InvalidValueException.php Class Class source
  Plain text file PropertyNotFoundException.php Class Class source

  Files folder image Files  /  src  /  Exceptions  /  Scalars  
File Role Description
Files folder imageString (1 file)

  Files folder image Files  /  src  /  Exceptions  /  Scalars  /  String  
File Role Description
  Plain text file RegexMatchException.php Class Class source

  Files folder image Files  /  src  /  Facades  
File Role Description
Files folder imageScalars (4 files)
  Plain text file ValueObjectFacade.php Class Class source

  Files folder image Files  /  src  /  Facades  /  Scalars  
File Role Description
  Plain text file BoolFacade.php Class Class source
  Plain text file FloatFacade.php Class Class source
  Plain text file IntFacade.php Class Class source
  Plain text file StringFacade.php Class Class source

  Files folder image Files  /  src  /  Scalars  
File Role Description
Files folder imageExtensions (4 directories)
  Plain text file BoolObject.php Class Class source
  Plain text file FloatObject.php Class Class source
  Plain text file IntObject.php Class Class source
  Plain text file StringObject.php Class Class source

  Files folder image Files  /  src  /  Scalars  /  Extensions  
File Role Description
Files folder imageBool (5 files)
Files folder imageFloat (2 files)
Files folder imageInt (3 files)
Files folder imageString (32 files)

  Files folder image Files  /  src  /  Scalars  /  Extensions  /  Bool  
File Role Description
  Plain text file BoolAndExtension.php Class Class source
  Plain text file BoolEqualsExtension.php Class Class source
  Plain text file BoolNotExtension.php Class Class source
  Plain text file BoolOrExtension.php Class Class source
  Plain text file BoolXorExtension.php Class Class source

  Files folder image Files  /  src  /  Scalars  /  Extensions  /  Float  
File Role Description
  Plain text file FloatCompareExtension.php Class Class source
  Plain text file FloatEqualsExtension.php Class Class source

  Files folder image Files  /  src  /  Scalars  /  Extensions  /  Int  
File Role Description
  Plain text file IntAbsExtension.php Class Class source
  Plain text file IntCompareExtension.php Class Class source
  Plain text file IntEqualsExtension.php Class Class source

  Files folder image Files  /  src  /  Scalars  /  Extensions  /  String  
File Role Description
  Plain text file StringAfterExtension.php Class Class source
  Plain text file StringAsciiExtension.php Class Class source
  Plain text file StringBeforeExtension.php Class Class source
  Plain text file StringCamelExtension.php Class Class source
  Plain text file StringCompareExtension.php Class Class source
  Plain text file StringConcatExtension.php Class Class source
  Plain text file StringContainsExtension.php Class Class source
  Plain text file StringEndsWithExtension.php Class Class source
  Plain text file StringEqualsExtension.php Class Class source
  Plain text file StringFinishExtension.php Class Class source
  Plain text file StringIsExtension.php Class Class source
  Plain text file StringKebabExtension.php Class Class source
  Plain text file StringLcfirstExtension.php Class Class source
  Plain text file StringLengthExtension.php Class Class source
  Plain text file StringLimitExtension.php Class Class source
  Plain text file StringLowerExtension.php Class Class source
  Plain text file StringRegexMatchesExtension.php Class Class source
  Plain text file StringRegexQuoteExtension.php Class Class source
  Plain text file StringReplaceArrayExtension.php Class Class source
  Plain text file StringReplaceExtension.php Class Class source
  Plain text file StringReplaceFirstExtension.php Class Class source
  Plain text file StringReplaceLastExtension.php Class Class source
  Plain text file StringSlugExtension.php Class Class source
  Plain text file StringSnakeExtension.php Class Class source
  Plain text file StringStartExtension.php Class Class source
  Plain text file StringStartsWithExtension.php Class Class source
  Plain text file StringStudlyExtension.php Class Class source
  Plain text file StringSubstrExtension.php Class Class source
  Plain text file StringTitleExtension.php Class Class source
  Plain text file StringUcfirstExtension.php Class Class source
  Plain text file StringUpperExtension.php Class Class source
  Plain text file StringWordsExtension.php Class Class source

  Files folder image Files  /  src  /  Support  
File Role Description
  Plain text file Character.php Class Class source

  Files folder image Files  /  src  /  Traits  
File Role Description
  Plain text file HasPropertyAccessors.php Class Class source
  Plain text file HasPropertyMutators.php Class Class source

  Files folder image Files  /  tests  
File Role Description
Files folder imageFeature (1 file)
Files folder imageHelpers (3 files, 1 directory)
Files folder imageUnit (2 files, 3 directories)
  Plain text file TestCase.php Class Class source

  Files folder image Files  /  tests  /  Feature  
File Role Description
  Plain text file ExampleTest.php Class Class source

  Files folder image Files  /  tests  /  Helpers  
File Role Description
Files folder imageFacades (3 files)
  Plain text file DummyNonValueObject.php Class Class source
  Plain text file DummyValueObject.php Class Class source
  Plain text file ImmutableDummy.php Class Class source

  Files folder image Files  /  tests  /  Helpers  /  Facades  
File Role Description
  Plain text file DummyCompleteFacade.php Class Class source
  Plain text file DummyInvalidFacade.php Class Class source
  Plain text file DummyNonValueObjectFacade.php Class Class source

  Files folder image Files  /  tests  /  Unit  
File Role Description
Files folder imageCollections (1 file)
Files folder imageFacade (1 file)
Files folder imageScalars (4 files, 4 directories)
  Plain text file ImmutableObjectTest.php Class Class source
  Plain text file ValueObjectTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Collections  
File Role Description
  Plain text file DotArrayTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Facade  
File Role Description
  Plain text file ValueObjectFacadeTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Scalars  
File Role Description
Files folder imageBool (4 files)
Files folder imageFloat (2 files)
Files folder imageInt (3 files)
Files folder imageString (33 files)
  Plain text file BoolObjectTest.php Class Class source
  Plain text file FloatObjectTest.php Class Class source
  Plain text file IntObjectTest.php Class Class source
  Plain text file StringObjectTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Scalars  /  Bool  
File Role Description
  Plain text file BoolAndTest.php Class Class source
  Plain text file BoolNotTest.php Class Class source
  Plain text file BoolOrTest.php Class Class source
  Plain text file BoolXorTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Scalars  /  Float  
File Role Description
  Plain text file FloatCompareTest.php Class Class source
  Plain text file FloatEqualsTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Scalars  /  Int  
File Role Description
  Plain text file IntAbsTest.php Class Class source
  Plain text file IntCompareTest.php Class Class source
  Plain text file IntEqualsTest.php Class Class source

  Files folder image Files  /  tests  /  Unit  /  Scalars  /  String  
File Role Description
  Plain text file StringAfterTest.php Class Class source
  Plain text file StringAsciiTest.php Class Class source
  Plain text file StringBeforeTest.php Class Class source
  Plain text file StringCamelTest.php Class Class source
  Plain text file StringCompareTest.php Class Class source
  Plain text file StringContainsTest.php Class Class source
  Plain text file StringEndsWithTest.php Class Class source
  Plain text file StringEqualsTest.php Class Class source
  Plain text file StringFinishTest.php Class Class source
  Plain text file StringIsTest.php Class Class source
  Plain text file StringKebabTest.php Class Class source
  Plain text file StringLcfirstTest.php Class Class source
  Plain text file StringLengthTest.php Class Class source
  Plain text file StringLimitTest.php Class Class source
  Plain text file StringLowerTest.php Class Class source
  Plain text file StringRandomTest.php Class Class source
  Plain text file StringRegexMatchesTest.php Class Class source
  Plain text file StringRegexQuoteTest.php Class Class source
  Plain text file StringReplaceArrayTest.php Class Class source
  Plain text file StringReplaceFirstTest.php Class Class source
  Plain text file StringReplaceLastTest.php Class Class source
  Plain text file StringReplaceTest.php Class Class source
  Plain text file StringSlugTest.php Class Class source
  Plain text file StringSnakeTest.php Class Class source
  Plain text file StringStartsWithTest.php Class Class source
  Plain text file StringStartTest.php Class Class source
  Plain text file StringStudlyTest.php Class Class source
  Plain text file StringSubstrTest.php Class Class source
  Plain text file StringTitleTest.php Class Class source
  Plain text file StringUcfirstTest.php Class Class source
  Plain text file StringUpperTest.php Class Class source
  Plain text file StringUuidTest.php Class Class source
  Plain text file StringWordsTest.php Class Class source

 Version Control Unique User Downloads Download Rankings  
 100%
Total:43
This week:8
All time:9,523
This week:51Up