Download the PHP package datingvip/accessor without Composer

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

Accessor

Release Code Quality Code Coverage Downloads

The icanboogie/accessor package allows classes to implement ICanBoogie's accessor design pattern. Using a combination of getters, setters, properties, and property visibilities, you can create read-only properties, write-only properties, virtual properties; and implement defaults, type control, guarding, and lazy loading.

Installation

Preamble

Because the package is a citizen of ICanBoogie's realm, which elected snake case a long time ago for its readability, the following examples use the same casing, but CamelCase is equally supported as we'll learn by the end of this document. Actually, because all getters and setters are formatted using the accessor_format trait method it is very easy to bind the formatting to one's requirements simply by overriding that method.

Getters and setters

A getter is a method that gets the value of a specific property. A setter is a method that sets the value of a specific property. You can define getters and setters on classes using the AccessorTrait trait, and optionally inform of its feature by implementing the HasAccessor interface.

Something to remember: Getters and setters are only invoked when their corresponding property is not accessible. This is most notably important to remember when using lazy loading, which creates the associated property when it is invoked.

Another thing to remember: You don't need to use getter/setter for everything and their cats, PHP is no Java, and it's okay to have public properties.

Read-only properties

Read-only properties are created by defining only a getter. A PropertyNotWritable exception is thrown in attempt to set a read-only property.

The following example demonstrates how a property read-only property can be implemented:

An existing property can be made read-only by setting its visibility to protected or private:

Protecting a construct property

Read-only properties are often used to provide read access to a property that was provided during construct, which should stay unchanged during the life time of an instance.

The following example demonstrates how a connection property passed during construct can only be read afterwards. The visibility of the property is set to private so that even an extending class cannot modify the property.

Write-only properties

Write-only properties are created by defining only a setter. A PropertyNotReadable exception is thrown in attempt to get a write-only property.

The following example demonstrates how a property write-only property can be implemented:

An existing property can be made write-only by setting its visibility to protected or private:

Virtual properties

A virtual property is created by defining a getter and a setter but no corresponding property. Virtual properties are usually providing an interface to another property or data structure.

The following example demonstrates how a minutes virtual property can be implemented as an interface to a seconds property.

Providing a default value until a property is set

Because getters are invoked when their corresponding property is inaccessible, and because an unset property is of course inaccessible, it is possible to define getters providing default values until a value is actually set.

The following example demonstrates how a default value can be provided while a property is inaccessible (unset an that case). During construct, if the slug property is empty it is unset, making it inaccessible. Thus, until the property is actually set, when the slug property is read its getter is invoked and returns a default value created from the title property.

Façade properties (and type control)

Sometimes you want to be able to manage the type of a property, what can be stored, what can be retrieved, the most transparently possible. This can be achieved with façade properties.

Façade properties are implemented by defining a private property along with its getter and setter.

The following example demonstrates how a created_at property is implemented. It can be set to a mixed value, but is always read as a DateTime instance.

Façade properties are exported on serialization

Although façade properties are defined using private properties, they are exported when the instance is serialized, just like they would if they were public or protected.

Lazy loading

Lazy loading creates the associated property when it is invoked, making subsequent accesses using the property rather than the getter.

In the following example, the lazy_get_pseudo_uniqid() getter returns a unique value, but because the pseudo_uniqid property is created with the public visibility after the getter was called, any subsequent access to the property returns the same value:

Of course, unsetting the created property resets the process.

Setting a lazy property

Lazy properties are implemented similarly to read-only properties, by defining a method to get a value, but unlike read-only properties lazy properties can be written too:

You need to remember that lazy properties actually create a property, thus the getter won't be invoked if the property is already accessible.

Overloading getters and setters

Because getters and setters are classic methods, they can be overloaded. That is, the setter or getter of a parent class can be overloaded by an extending class.

The following example demonstrates how an Awesome class extending an Plain class can turn a plain getter into an awesome getter:

CamelCase support

CamelCase getters and setters are equally supported. Instead of using the AccessorTrait, use the AccessorCamelTrait:


Continuous Integration

The project is continuously tested by GitHub actions.

Tests Static Analysis Code Style

Code of Conduct

This project adheres to a Contributor Code of Conduct. By participating in this project and its community, you are expected to uphold this code.

Contributing

Please see CONTRIBUTING for details.

License

icanboogie/accessor is released under the BSD-3-Clause.


All versions of accessor with dependencies

PHP Build Version
Package Version
Requires php Version >=7.2.5
icanboogie/common Version ^1.3.2|^2.0|^6.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 datingvip/accessor contains the following files

Loading the files please wait ....