icanboogie/bind-facets

Binds icanboogie/facets to ICanBoogie

v5.0.0 2021-06-01 19:50 UTC

This package is auto-updated.

Last update: 2022-09-23 13:32:32 UTC


README

Release Build Status Code Quality Code Coverage Packagist

The icanboogie/bind-facets package binds icanboogie/facets to ICanBoogie, using its autoconfig feature, and provides the following features:

  • A synthesizer for the activerecord_facets config.
  • A criteria prototype property for Model instances.
  • A criterion_list prototype property for Model instances.
  • A fetch_record() prototype method for Model instances.
  • A fetch_records() prototype method for Model instances.

Hinting prototype bindings

Because most features are provided through prototype methods, your favorite editor might complain about unknown methods, in which case simply use the ModelBindings trait.

The following example demonstrates how to hint your code about a fetch_records method. Notice the type hint in the annotation Model|ModelBindings:

<?php

use ICanBoogie\ActiveRecord\Model;
use ICanBoogie\Binding\Facets\ModelBindings;
use ICanBoogie\Facets\RecordCollection;

/**
 * @param Model|ModelBindings
 *
 * @return RecordCollection
 */
function fetch(Model $model, array $conditions)
{
    return $model->fetch_records($conditions;
}

Requirements

The package requires PHP 7.2 or later.

Installation

composer require icanboogie/bind-facets

Documentation

The package is documented as part of the ICanBoogie framework documentation. You can generate the documentation for the package and its dependencies with the make doc command. The documentation is generated in the build/docs directory. ApiGen is required. The directory can later be cleaned with the make clean command.

Testing

Run make test-container to create and log into the test container, then run make test to run the test suite. Alternatively, run make test-coverage to run the test suite with test coverage. Open build/coverage/index.html to see the breakdown of the code coverage.

License

icanboogie/bind-facets is released under the New BSD License.