Skip to content

christopher-evans/php-uri

Repository files navigation

West\Uri

An RFC 3986 URI implementation.

Autoloading

This package is PSR-4 autoloadable via composer or otherwise mapping the West\Uri namespace to the src/ directory. To run the tests the West\Uri namespace should map to the tests/ directory.

Dependencies

This package requires PHP 7.1 or later; there are external interfaces required by the package.

Code Quality

To run the unit tests and generate a coverage report with PHPUnit run composer install followed by composer test at the command line.

This package should comply with the recommendations set out in PSR-1, PSR-2 and PSR-4.

To run the benchmarks and generate a report with PHPBench run composer install followed by composer benchmark at the command line. For details about the reports see the the composer.json file and the PHPBenchDocs.

Documentation

This package is documented here. To generate the docs run run composer install --no-dev, ensure Doxygen is installed and available as doxygen and run composer docs.

Principles

The aim of this package is to implement some of the principles of object oriented programming described in David West's Object Thinking. Many of the ideas come from Yegor Bugayenko's distillations of West's book, and Alan Kay's comments on Squeak and Smalltalk. In particular:

  • Everything is an object.

    Some exceptions are permitted, for example the introduction of resources, in part to compensate for the lack of OOP in earlier versions of the language, are allowed.

  • An object exists in real life.

  • An object is unique.

    Some exceptions are permitted, for example two objects encapsulating distinct URIs may point to the same resource without aggressive URI normalization.

  • An object is immutable.

    Various definitions of immutability can be contended, e.g. a file object representing a file in a mutable filesystem are considered mutable regardless of whether an changes to the file are visible through the object.

  • A class name does not end in '-er'.

    An object is a thing, and a class name described what objects of that class are, not what they do. Verbs are used for method names.

  • There are no null values.

    The special value null is not an instance of any class, and does not implement any (useful) interface. An object that does not implement the interfaces expected of it's fellow class members does not exist.

  • A class does not have any static properties or methods.

    An application consists of objects interacting through interfaces, and classes are used to describe sets of objects, not to implement logic for those objects.

  • A class is either abstract or final. Only abstract methods are protected.

    An object is the master of it's internal behavior, and works with other objects only through it's public interface. Extending a 'completed' class may break the logic of the parent class. Allowing abstract classes at all is a concession with which the author is increasingly unhappy.

  • Objects interact through interfaces.

    Objects judge objects based on what they do, not what they are. A public method not documented by an interface would be redundant.

Releases

No releases published

Packages

No packages published

Languages