Download the PHP package smartemailing/types without Composer

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

SmartEmailing \ Types

Missing data types for PHP 8.1. Highly extendable, production tested.

MIT license Latest release Downloads

Build Status Code coverage CodeClimate

Neverending data validation can be exhausting. Either you have to validate your data over and over again in every function you use it, or you have to rely it has already been validated somewhere else and risk potential problems.

Smelly, right?

Replacing validation hell with Types will make your code much more readable and less vulnerable to bugs.

Types wrap your data in value objects that are guaranteed to be valid and normalized; or not to exist at all. It allows you to use specific type hints instead of primitive types or arrays. Your code will be unbreakable and your IDE will love it.

Table of Contents

Installation

The recommended way to install is via Composer:

How does it work

It is easy. You just initialize desired value object by simple one-liner. From this point, you have sanitized, normalized and valid data; or SmartEmailing\Types\InvalidTypeException to handle.

Types consist from:

Different types provide different methods related to them, but all types share this extraction API:

Wrapping raw value

Extraction from array

This is really useful for strict-typing (validation) multidimensional arrays like API requests, forms or database data.

String-extractable types

String-extractable types are based on validated strings. All values are trimmed before validation.

They can be easily converted back to string by string-type casting or calling $type->getValue().

E-mail address

SmartEmailing\Types\Emailaddress

Lowercased and ASCII-transformed e-mail address ([email protected])

Type-specific methods:

Non-empty string

SmartEmailing\Types\NonEmptyString

Trimmed non-empty string.

Domain

SmartEmailing\Types\Domain

Lowercased domain name (mx1.googlemx.google.com)

Type-specific methods:

Hex 32

SmartEmailing\Types\Hex32

Lowercased 32-characters long hexadecimal string useful as container for MD5 or UUID without dashes. (741ecf779c9244358e6b85975bd13452)

Hex color

SmartEmailing\Types\HexColor

Uppercased 7-characters long string useful as container for color. (#006EDB)

GUID

SmartEmailing\Types\Guid

Lowercased Guid with dashes (741ecf77-9c92-4435-8e6b-85975bd13452)

IP address

SmartEmailing\Types\IpAddress

IP address v4 or v6. (127.0.0.1, [2001:0db8:0a0b:12f0:0000:0000:0000:0001], 2001:db8:a0b:12f0::1)

Type-specific methods:

URL

SmartEmailing\Types\UrlType

URL based on Nette\Http\Url (https://www.google.com/search?q=all+work+and+no+play+makes+jack+a+dull+boy)

Type-specific methods:

Company registration number

SmartEmailing\Types\CompanyRegistrationNumber

Whitespace-free company registration number for following countries: CZ, SK, CY

Phone number

SmartEmailing\Types\PhoneNumber

Whitespace-free phone number in international format for following countries: CZ, SK, AT, BE, FR, HU, GB, DE, US, PL, IT, SE, SI, MH, NL, CY, IE, DK, FI, LU, TR

Type-specific methods:

ZIP code

SmartEmailing\Types\ZipCode

Whitespace-free ZIP code valid in following countries: CZ, SK, UK, US

JSON

SmartEmailing\Types\JsonString

Valid JSON-encoded data as string

Type-specific methods:

Base 64

SmartEmailing\Types\Base64String

Valid Base 64-encoded data as string

Type-specific methods:

Iban

SmartEmailing\Types\Iban

Type-specific methods:

SwiftBic

SmartEmailing\Types\SwiftBic

Valid Swift/Bic codes.

VatId

SmartEmailing\Types\VatId

Type-specific methods:

CurrencyCode

SmartEmailing\Types\CurrencyCode

Valid currency codes by ISO 4217

CountryCode

SmartEmailing\Types\CountryCode

Valid country codes by ISO 3166-1 alpha-2

Int-extractable types

Int-extractable types are based on validated integers.

They can be easily converted back to int by int-type casting or calling $type->getValue().

Port

SmartEmailing\Types\Port

Port number

Integer interval, <0, 65535>

Quantity

SmartEmailing\Types\Quantity

Quantity of items

Integer interval, <1, PHP_INT_MAX>

Unsigned Integer

SmartEmailing\Types\UnsignedInt

Usigned integer

Integer interval, <0, PHP_INT_MAX>

Float-extractable types

Float-extractable types are based on validated floats.

They can be easily converted back to float by float-type casting or calling $type->getValue().

Part

SmartEmailing\Types\Part

Portion of the whole

Float interval <0.0, 1.0>

Type-specific methods:

Sigmoid function value

SmartEmailing\Types\SigmoidValue

Result of Sigmoid function, useful when building neural networks.

Float interval <-1.0, 1.0>.

Rectified Linear Unit function value

SmartEmailing\Types\ReLUValue

Result of Rectified Linear Unit function, useful when building neural networks.

Float interval <0.0, Infinity).

Unsigned Float

SmartEmailing\Types\UnsignedFloat

Usigned float

Float interval, <0, PHP_FLOAT_MAX>

Array-extractable types

Array-extractable types are composite types encapsulating one or more another types. They are created from associative array. All Array-extractable types implement method toArray() : array which returns normalized array or type's data.

DateTimeRange

SmartEmailing\Types\DateTimeRange

Range between two \DateTimeInterfaces. Safe for datetimes out of range of unix timestamp.

Can be created from:

Type-specific methods:

Duration

SmartEmailing\Types\Duration

Human-readable time interval.

Can be created from:

Type-specific methods:

Address

SmartEmailing\Types\Address

Location address contains street and number, town, zip code and country.

Can be created from:

Type-specific methods:

Price

SmartEmailing\Types\Price

Price object containing number of currency units with VAT, number of currency units without VAT and currency.

Can be created from:

Type-specific methods:

Login credentials

SmartEmailing\Types\LoginCredentials

Value object containing login and plain password. You should use it just in-memory in authentication process and than drop it.

Can be created from:

Type-specific methods:

Key-Value pair

SmartEmailing\Types\KeyValue

Value object containing string key and string value.

Can be created from:

Type-specific methods:

Scalar leaves array

SmartEmailing\Types\ScalarLeavesArray

Value object containing single or multi-dimensional array with only scalar or NULL values in it's leaves. Array keys stay untouched.

Can be created from:

Array-types-specific extractors:

Array-types

Types provide another kind of Array-extractable types: Unique primitive-type arrays. Their purpose is to hold unique set of primitives. They implement \Countable and \IteratorAggregate and natively support set operations.

All Array-types share following features:

Array-types-specific extractors:

UniqueIntArray

SmartEmailing\Types\UniqueIntArray

UniqueIntArray is able to hold unique set of integers.

Can be created from:

Type-specific methods:

UniqueStringArray

SmartEmailing\Types\UniqueIntArray

UniqueStringArray is able to hold unique set of strings.

Can be created from:

Type-specific methods:

Enum-extractable types

Enum-extractable types are types that can contain single value from defined set. They are based on kkk

All Enum-extractable types share following features:

Enums can be created using standard extractors or using their constants:

Lawful Basis For Processing

SmartEmailing\Types\LawfulBasisForProcessing

GDPR's lawful basis for processing

Available values

Country code

SmartEmailing\Types\CountryCode

ISO-3166-1 Alpha 2 country code

Available values

Currency code

SmartEmailing\Types\CurrencyCode

ISO-4217 three-letter currency code

Available values

Field of Application

SmartEmailing\Types\FieldOfApplication

Most common fields of human applications.

Available values

Time unit

SmartEmailing\Types\TimeUnit

Time unit compatible with \DateTime::modify() argument format

Available values

Relation

SmartEmailing\Types\Relation

Represents Relation or Gate - AND / OR

Available values

Primitive types and Arrays

Types are able to get and extract primitives using IntType, IntArray, FloatType, FloatArray, StringType, StringArray, BoolType, BoolArray and Array classes. See examples below:

DateTimes and DateTimesImmutable

Types are able to get and extract \DateTime and \DateTimeImmutable objects using DateTimes and DateTimesImmutable classes. Supported format Y-m-d H:s:i. API is the same as for other types, so available methods are (shown for DateTimes):

Dates and DatesImmutable

Types are able to get and extract \DateTime and \DateTimeImmutable objects using Dates and DatesImmutable classes. Dates are created with time sets on 00:00:00. Supported format Y-m-d. API is the same as for other types, so available methods are (shown for Dates):

Writing your own types

Implementing your custom type is easy! At first you have to decide what extractable-type should your new custom type be and use particular extractable-trait in it's class to enhance it by all extractable features. The only thing you have to do next is implement class construtor and throw InvalidTypeException in case of invalid data. You can see examples for every extractable-type below.

One more thought - if you think your new type will be useful for others, please, contribute!

How to contribute

Thank you for your interest in improving Types!️ ❤️ 🖖

Before you open pull request, please, make sure you did not forget to write tests for your code.

Then run following commands:

1) vendor/bin/tester tests Run tests locally. It takes just two seconds :-)

2) bin/cbf This will check the code and automatically fix some code style issues like indentation or line breaks.

3) bin/cs This will run another code style check that will notify you about problems that must be fixed manually. Please, fix them, and re-run the command.

4) bin/stan PHP Static analysis tool - this will check the code for some smelly constructions that should be refactored. Please, fix them, and re-run the command.

5) PR ready!

We are hiring

Do you like our code? If you want to be part of SmartEmailing, we are hiring.


All versions of types with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
nette/utils Version ^3.0|^4.0
nette/http Version ^3.0
egulias/email-validator Version ^3.1.1|^4.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 smartemailing/types contains the following files

Loading the files please wait ....