Download the PHP package starburst/utils without Composer

On this page you can find all versions of the php package starburst/utils. 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 utils

Starburst Utils

Latest Version on Packagist

Package that contain some common helper classes

Requirements

PHP 8.0 or higher.

Installation

Usage

Json

The Starburst\Utils\Json class provides static methods for encoding and decoding Json in PHP. Below, you'll find detailed documentation on how to use it:

encode(mixed $value, bool $encodeNull = true): ?string

This method accepts a variable of any type and converts it to a JSON string.

Parameters:

Returns:

Usage:

decode(string $value): mixed

This method accepts a JSON string and decodes it to the corresponding PHP value or array.

Parameters:

Returns:

Usage:

decodeArray(string $value, bool $allowNull = false): ?array

This method decodes a JSON string to an associative array in PHP.

The method throws a JsonException if the decoded value is not an array.

Parameters:

Returns:

Usage:

decodeList(string $value, bool $allowNull = false): ?array

This method decodes a JSON string to a numeric array (list) in PHP.

The method throws a JsonException if the decoded value is not a list.

Parameters:

Returns:

Usage:

Validators

The Starburst\Utils\Validators class provides static methods to validate different types of input.

isUnicode(mixed $value): bool

This function checks if the provided value is a valid UTF-8 string.

Parameters:

Returns:

Usage:

isKennitala(mixed $value): bool

This function checks if the provided value is a valid kennitala.

Parameters:

Returns:

Usage:

isEmail(string $value): bool

This function checks if the provided string is a valid email address. Note that it only checks the syntax of the email and not if the email domain actually exists.

Parameters:

Returns:

Usage:

isIcelandicPhoneNumber(string $value): bool

This function checks if the provided string is a valid icelandic phone number.

Parameters:

Returns:

Usage:

Text

Static class that helps normalize texts

normalize(string $value): string

Removes control characters, normalizes line breaks to \n, removes leading and trailing blank lines, trims end spaces on lines, normalizes UTF-8 to the normal form of NFC.

truncate(string $string, int $maxLen, string $append = "\u{2026}"): string

Truncates a UTF-8 string to a given maximal length while trying not to split whole words. Only if the string is truncated, an ellipsis (or something else set with the third argument) is appended to the string.

slugify(string $string, string $separator = '-', bool $allowPeriod = false, string $locale = 'is'): string

Converts a string into a URL-friendly slug by transliterating characters based on locale-specific rules.

Supported locales: 'de', 'is', 'en', 'ru', 'uk'

normalizeIcelandicPhoneNumber(string $phoneNumber): string

Normalizes a phone number to the format +3541234567.

If it's not a valid Icelandic phone number, throws InvalidArgumentException

GetArrayCopy

Trait that helps convert an object into an assoc array.

It supports value resolvers that can be used to format some properties in a custom way.

Example

Configure custom value resolvers

Path

The Path class provides utility methods for working with file paths in a platform-independent manner.

normalize(string $path): string

Normalizes a given file path.

During normalization, all slashes are replaced by forward slashes ("/"). It also makes sure to remove trailing slashes. Contrary to canonicalize, this method does not remove invalid or dot path segments. Consequently, it is much more efficient and should be used whenever the given path is known to be a valid, absolute system path.

Example:

canonicalize(string $path): string

Normalizes and canonicalizes a given file path.

Example:

join(string ...$parts): string

Joins multiple parts into on a normalized and canonicalized path

Example:


All versions of utils with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-intl Version *
ext-mbstring Version *
sunkan/dictus Version ^2.0
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 starburst/utils contains the following files

Loading the files please wait ...