Skip to content

Basic classes and helpers shared by some ICanBoogie packages

License

Notifications You must be signed in to change notification settings

ICanBoogie/Common

Repository files navigation

Common

Release Code Coverage Packagist

This package provides basic classes and helpers shared by many ICanBoogie packages. It provides offset exceptions, property exceptions, some interfaces, and helpers to transform strings and arrays.

Installation

composer require icanboogie/common

Exceptions

Offset exceptions

The package defines the following exceptions related to array offset:

Property exceptions

The following exceptions related to object properties defined by the package:

<?php

use ICanBoogie\PropertyNotDefined;

class A
{
	private $id;

	public function __get(string $property)
	{
		if ($property === 'id') {
			return $this->id;
		}

		throw new PropertyNotDefined([ $property, $this ]);
	}
}

Interfaces

The package defines the following interfaces:

  • ToArray: Should be implemented by classes whose instances can be converted into arrays.
  • ToArrayRecursive: Should be implemented by classes whose instances can be converted into arrays recursively.
<?php

use ICanBoogie\ToArray;
use ICanBoogie\ToArrayRecursive;

class A implements ToArrayRecursive
{
	use ToArrayRecursiveTrait;

	public function to_array(): array
	{
		return (array) $this;
	}
}

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're expected to uphold this code.

Contributing

See CONTRIBUTING for details.

About

Basic classes and helpers shared by some ICanBoogie packages

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published