2017 © Pedro Peláez
 

library tools

Just some tools to work better with PHP

image

nekland/tools

Just some tools to work better with PHP

  • Friday, July 13, 2018
  • by Nek
  • Repository
  • 4 Watchers
  • 2 Stars
  • 2,884 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 9 Versions
  • 43 % Grown

The README.md

Nekland Tools

Build Status, (*1)

Just some classes helping to code with PHP in general. No dependencies. High quality code., (*2)

This repository follows semver., (*3)

Installation

composer require "nekland/tools"

Reference

This library provide some tools to help you with your developments., (*4)

Here is the list of tools it provides: - StringTools - ArrayTools - EqualableInterface - DateTimeComparator - TemporaryFile - TemporaryDirectory, (*5)

StringTools class

Encoding arguments are optionals., (*6)

::camelize

StringTools::camelize($str, $from, $encoding, $normalize = true) : string
  • $str string input
  • $from (optional, default "_") input string format (can be "-" or "_")
  • $encoding (optional, default "UTF-8") encoding of your input string
  • $normalize decide either you want to normalize (remove special characters) or not, that's what you want in most cases when camelizing

::startsWith

Say if the given string starts with needle or not., (*7)

StringTools::startsWith($str, $start) : bool
  • $str string input
  • $start string it should starts with

::endsWith

Say if the given string ends with needle or not., (*8)

StringTools::endsWith($str, $end) : bool
  • $str string input
  • $end string it should ends with

::removeStart

Removes the start of the string if it matches with the given one., (*9)

StringTools::removeStart($str, $toRemove) : string
  • $str string input
  • $toRemove string to remove at the start of $str

::removeEnd

Removes the end of the string if it matches with the given text to remove., (*10)

StringTools::removeEnd($str, $toRemove) : string
  • $str string input
  • $toRemove string to remove at the end of $str

::contains

StringTools::contains($str, $needle) : bool
  • $str string input
  • $needle potentially contained string

::mb_ucfirst

Adds missing multi-byte PHP function for ucfirst standard function., (*11)

StringTools::mb_ucfirst($str, $encoding) : string
  • $str string input
  • $encoding (optional, default "UTF-8") encoding of your input string

ArrayTools class

::removeValue

ArrayTools::removeValue($array, $value) : void
  • $array input array passed by reference
  • $value The value to remove from the $array

EqualableInterface

Helps you equals on objects on a similar way as java., (*12)

equals

Method that you must implements to check if the object taking as parameter is equals or not., (*13)

DateTimeComparator class

For following methods lowest and greatest, you can provide unlimited DateTimeInterface objects. Please note that non DateTimeInterface objects will be ignored by functions., (*14)

::greatest

Compare \DateTimeInterface from parameters and return the greatest, (*15)

DateTimeComparator::greatest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface

::lowest

Compare \DateTimeInterface from parameters and return the lowest, (*16)

DateTimeComparator::lowest($dateTime1, $dateTime2, $dateTime3, ...) : ?\DateTimeInterface

Temporary file management

The class TemporaryFile helps you to create temporary file with ease., (*17)

::__construct()

TemporaryFile::__construct(TemporaryDirectory $dir = null, string $prefix = '')

Examples:, (*18)

// Create a file in temporary folder
$file = new TemporaryFile();

// Create a file inside a temporary directory (see TemporaryDirectory class)
$file = new TemporaryFile($temporaryDir);

// Create a file in a temporary folder with php_ prefix.
$file = new TemporaryFile(null, 'php_');

::setContent & ::getContent

TemporaryFile::setContent(string $content)
TemporaryFile::getContent(): string

::getPathname()

Returns the complete path to the file (ie: /tmp/generated-folder/filename), (*19)

TemporaryFile::getPathname(): string

::remove()

Removes the file from filesystem., (*20)

TemporaryFile::remove()

Temporary directory management

::__construct()

TemporaryDirectory::__construct(string $dir = null, string $prefix = 'phpgenerated')

Examples:, (*21)

// create a new directory
$directory = new TemporaryDirectory();

::getTemporaryFile()

Create a TemporaryFile from the directory generated., (*22)

TemporaryDirectory::getTemporaryFile(): TemporaryFile

::remove()

Removes the directory., (*23)

TemporaryDirectory::remove(bool $force = false): void

If force is specified to true, it will remove the directory even if it has files inside., (*24)

::getPathname()

Returns the complete path to the folder (ie: /tmp/folder-name), (*25)

TemporaryDirectory::getPathname(): string

The Versions

13/07 2018

dev-master

9999999-dev

Just some tools to work better with PHP

  Sources   Download

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

13/07 2018

2.2.0

2.2.0.0

Just some tools to work better with PHP

  Sources   Download

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

12/07 2018

dev-feature/array-tools

dev-feature/array-tools

Just some tools to work better with PHP

  Sources   Download

The Requires

  • php ^5.6 || ^7.0

 

The Development Requires

23/04 2018

dev-doc/highlight-components

dev-doc/highlight-components

Just some tools to work better with PHP

  Sources   Download

The Development Requires

23/04 2018

2.1.0

2.1.0.0

Just some tools to work better with PHP

  Sources   Download

The Development Requires

23/04 2018

dev-feature/datetime-comparator

dev-feature/datetime-comparator

Just some tools to work better with PHP

  Sources   Download

The Development Requires

01/08 2017

2.0.0

2.0.0.0

Just some tools to work better with PHP

  Sources   Download

The Development Requires

09/05 2017

dev-Nek--patch-1

dev-Nek--patch-1

Just some tools to work better with PHP

  Sources   Download

The Development Requires

03/11 2016

1.0.0

1.0.0.0

Just some tools to work better with PHP

  Sources   Download

The Development Requires