Download the PHP package brimshot/pattr without Composer

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

Pattr

A straightforward and simple library for using attributes in PHP.

Installation

Install with composer:

Or download directly from:

https://github.com/brimshot/Pattr

Usage

Pattr provides functions meant to simplify working with attributes in PHP.

Make the functions accessible in your code by including vendor/autoload.php (when using composer) or by including src/Pattr.php directly.

Import each function you intend to use with a use directive at the top of your source file, i.e.:

The functions in the library operate on classes (or instantiated objects), public class properties, class methods, class constants and globally available functions.

To get information about a class or object property or method, pass the details as an array i.e. [Object, MethodName]

Function list


 

has_attribute(mixed $item, string|array $attribute_or_array_of_attributes, bool $matchChildAttributes = true) : bool

Returns true or false whether the provided item has the provided attribute or all of the provided attributes if $attribute_or_array_of_attributes is an array.

By default, child classes of provided attributes will be matched but this can be disabled (strict mode) by passing false as the third argument.

$attribute_or_array_of_attributes can also be a string (or strings) in which case the unqualified classname will be matched.

Example:


has_attribute_callback(mixed $item, string $attribute, callable $callback, $matchChildAttributes = true) : bool

Returns true or false whether the provided item has the provided attribute and the attribute, when instantiated, satisfies the provided callback. By default, child attributes of the provided attribute will also be matched.

Example:


does_not_have_attribute(mixed $item, string|array $attribute_or_array_of_attributes, bool $matchChildAttributes = true) : bool

Returns true if the provided item does not have the provided attribute or if $attribute_or_array_of_attributes is an array, returns true if the item does not have any of the provided attributes.

Example:


get_attribute_names(mixed $item, bool $shortNames = false) : array

Returns the names of the provided items attributes. Default is the fully qualified class name, but names can be shortened by passing true for $shortNames.

Example:


get_attribute(mixed $item, string $attribute, bool $matchChildAttributes = true, int $index = 0) : ?object

Returns an instance of the requested attribute from the provided item, or null if item does not have the desired attribute.

An optional index parameter can be provided for use with repeated attributes to select which to return (index begins at 0).

Example:


get_attributes(mixed $item, array $attribute_list = [], bool $matchChildAttributes = true) : array

Returns an array of instances of the provided items attributes. Can be filtered to a desired subset by passing in $attribute_list. By default, children of attributes provided in the filter list are included in the result set.

Example:


get_attributes_callback(mixed $item, string $attribute, callable $callback, $matchChildAttributes = true) : array

Returns an array of instances of the requested attribute (array contains multiple results on repeated attributes) from the provided item when those attribute(s) satisfy the provided callback, or an empty array when none match.


get_class_methods_with_attribute(object|string $object_or_class, string|array $attribute_or_array_of_attributes, bool $matchChildAttributes = true) : array

Returns an array of method names from the given class or object that have the provided attribute or array of attributes. By default, children of attributes provided in search list are included in the result set.

Example:


get_class_methods_with_attribute_callback(object|string $object_or_class, string $attribute, callable $callback, bool $matchChildAttributes = true) : array

Returns an array of method names from the given class or object that have the provided attribute and that attribute satisfies the provided callback. By default, children of attributes provided in search list are included in the result set.

Example:


get_object_properties_with_attribute(object $object, string|array $attribute_or_array_of_attributes, bool $matchChildAttributes = true) : array

Returns an array of property names and their values from an instantiated object that have the provided attributes or array of attributes. By default, children of attributes provided in search list are included in the result set.


get_object_properties_with_attribute_callback(object $object, string $attribute, callable $callback, $matchChildAttributes = true) : array

Returns an array of property names and their values from an instantiated object that have the provided attribute and that attribute satisfies the provided callback.

Example:


get_class_properties_with_attribute(string $class, string|array $attribute_or_array_of_attributes, bool $matchChildAttributes = true) : array

Returns an array of property names from a class (not instantiated) that have the provided attributes or array of attributes. By default, children of attributes provided in search list are included in the result set.

Example:


get_class_properties_with_attribute_callback(string $class, string $attribute, callable $callback) : array

Returns an array of property names from a class (not instantiated) that have the provided attribute and that attribute satisfies the provided callback.

Example:


get_class_constants_with_attribute(string|object $class_or_object, string|array $attribute_or_array_of_attributes) : array

Returns an array of constant names and their values from a class or object that have the provided attributes or array of attributes. By default, children of attributes provided in search list are included in the result set.

Example:


get_class_constants_with_attribute_callback(string|object $class_or_object, string $attribute, callable $callback, bool $matchAttributeChildren = true) : array

Returns an array of constant names and their values from a class or object that have the provided attribute and that attribute satisfies the provided callback. By default, children of attributes provided in search list are included in the result set.

Example:


Copyright (c) Chris Brim 2022, see LICENSE file


All versions of pattr with dependencies

PHP Build Version
Package Version
Requires php Version >=8.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 brimshot/pattr contains the following files

Loading the files please wait ....