Download the PHP package torugo/tstring without Composer

On this page you can find all versions of the php package torugo/tstring. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package tstring

TString

Small toolset for validating and handling strings.

Inspired on validator.js.

Table of Contents

Requirements

Installation

Usage

You can use this library in two ways, using specific Traits or instantiating the TString class.

Via Traits

Traits are a good way to use only the functions you need, just use them within your classes.

[!NOTE] All valitors and manipulators traits functions visibility are protected static.

Via TString static object

TString class is the easiest way to use the functions of this library, by using it you will have access to all features in a single object.

Validators

contains

Checks if a substring is contained in another string.

[!NOTE] By default the case sensitiveness is enabled.

Trait Namespace

Examples

isAlpha

Validates if a string have only alphabetical characters.

[!NOTE] When enabled, the argument $includeUnicode will include some unicode alphabetic characters like accented letters, and alphabetical characters from some languages. This option is disabled by default.

Trait Namespace

Examples

isAlphanumeric

Validates if a string have only alphanumeric characters.

[!NOTE] When enabled, the argument $includeUnicode will include some unicode alphabetic characters like accented letters, and alphabetical characters from some languages. This option is disabled by default.

Trait Namespace

Examples

isBase64

Validates whether a string is in Base64 format.
Also validates url safe Base64 strings.

Trait Namespace

Examples

isCnpj

Validates if a given string has a valid CNPJ registration.

The Brazil National Registry of Legal Entities number (CNPJ) is a company identification number that must be obtained from the Department of Federal Revenue(Secretaria da Receita Federal do Brasil) prior to the start of any business activities.

Trait Namespace

Examples

[!NOTE] This validator uses a validation code from Guilherme Sehn.

[!IMPORTANT] The cnpj numbers above were generated randomly using this tool.
If one of them belongs to you, please send me a request to remove.

isCpf

Validates if a given string has a valid CPF identification.

CPF Stands for “Cadastro de Pessoas Físicas” or “Registry of Individuals”. It is similar to the “Social Security” number adopted in the US, and it is used as a type of universal identifier in Brazil.

Trait Namespace

Examples

[!NOTE] This validator uses a validation code from Rafael Neri.

[!IMPORTANT] The CPF numbers above were generated randomly using this tool.
If one of them belongs to you, please send me a request and I will remove it immediately.

IsEmail

Validates if a string has a valid email structure.

Trait Namespace

Examples

[!TIP] Take a look at the tests to see more of valid or invalid e-mails.

IsHexadecimal

Validates if a string is a hexadecimal number.

Trait Namespace

Examples

isLength

Validates if the length of a string is between the minimum and maximum parameters.

[!IMPORTANT] If $min is negative it will be setted to 0 (zero).
If $max is lesser than 1 it will be setted to 1.
If $min is lesser than $max, their values will be swapped.

Trait Namespace

Examples

isNumeric

Validates if a string have only numeric characters.

Trait Namespace

Examples

isSemVer

Trait Namespace

Examples

isUrl

Validates if a string have only numeric characters.

[!NOTE] This validator is based on validator.js

Trait Namespace

Examples

UrlOptions

Default values:

maxLength

Validates if the length of a string is lesser than or equal to a maximum parameter.

Trait Namespace

Examples

minLength

Validates if the length of a string is greater than or equal to a minimum parameter.

Trait Namespace

Examples

maxVersion

Checks if a version number is lesser or equal to a given one.

This function validates version numbers that have only numbers sepatared by periods.

Trait Namespace

Examples

minVersion

Checks if a version is greater or equal to a given one.

This function validates version numbers that have only numbers sepatared by periods.

Trait Namespace

Examples

Handlers

toString

Tries to convert some types to string.

Types supported Notes
integer Simple int to string convertion
double Simple double to string convertion
boolean Returns 'true' or 'false' string values
array Implodes elements with an empty ('') separator by default
object Checks if object implements __toString() method, otherwise returns false
resource Tries to get the outup stream, returns false in case of fail
NULL Returns an empty string ('')

[!NOTE] Returns a string when succeed, and false on fail.
The $arraySeparator is used only when the value's type is 'array'.

Trait Namespace

Examples

toLowerCase

Changes the case of a string to lowercase.

Trait Namespace

Examples

toTitleCase

Changes the case of a string to title case, with options to fix Roman numerals and Portuguese language prepositions.

[!NOTE] The arguments $fixRomanNumerals and $fixPortuguesePrepositions are disabled by default.

Trait Namespace

Examples

toUpperCase

Changes the case of a string to uppercase.

Trait Namespace

Examples

Contribute

It is currently not open to contributions, I intend to make it available as soon as possible.

License

This library is licensed under the MIT License - see the LICENSE file for details.


All versions of tstring with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
ext-mbstring Version *
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package torugo/tstring contains the following files

Loading the files please wait ....