Download the PHP package robvanaarle/php-object-seam without Composer

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

PHP Object Seam

A lightweight toolkit for introducing object seams into legacy PHP code to make it testable - with minimal or no changes to the Class Under Test.

Legacy PHP code can be difficult to extend and test because dependencies are tightly coupled and often hidden behind private methods, static helpers, or heavy constructors. Although refactoring is ideal, complexity and time constraints often prevent it. To safely add new features or fix bugs, automated tests must come first - but those same dependencies make adding tests hard.

In Working Effectively with Legacy Code, Michael Feathers defines a seam as “a place to alter program behavior, without changing the code.”
This library provides an implementation of object seams, enabling you to:

All without or minimal modifications to the original class.

Installation

composer require --dev robvanaarle/php-object-seam:^1

Requirements

PHP >= 7.0. This package supports a wide range of PHP versions to accommodate legacy codebases.

Example

Testing TemperatureApi is difficult because the only public method makes an actual HTTP request, which is problematic because it is slow, unreliable, and may incur costs. It should be refactored if possible, but when that is not an option, we can use object seams to test it.

Without modifying the class, we can use an object seam to call the private method fahrenheitToCelsius() directly to test it:

The error handling of getCurrentTemperature() can be tested by first making a small change ('incision') to the TemperatureApi class: make getWeatherData() protected. This allows for overriding the method to return controlled data:

Features

These capabilities map directly to Feathers’ dependency-breaking techniques: 'Subclass and Make Public', 'Subclass and Override' and 'Expose Static Method'.

Introspection & Invocation

Behavior Overrides

Call Capturing

Object Construction

Developer Experience

Why Not Create Seams Manually?

Manually creating seams usually involves writing boilerplate subclasses or duplicated logic.
PHP Object Seam provides:

Basic Usage in tests

Usage Guide

Call non-public method

Call protected static method

Call non-public property hook

Override public or protected method

Overridden methods are executed in the scope of the object seam class.

Override with a Closure:

Override with a result value:

Override public or protected static method

Overridden static methods are executed in the scope of the object seam class.

Override with a Closure:

Override with a result value:

Override public or protected property hook

Overridden property hooks are executed in the scope of the object seam class.

Override with a Closure:

Override with a result value:

Instantiate an object with a custom constructor

or set a custom constructor and call it later:

Call original constructor

Often there is no need for a custom constructor; in that case, the original constructor can be called.

Capture and retrieve public and protected method calls

Capturing and retrieving calls allows for asserting that a method has been called and with which arguments.

Capture and retrieve public and protected static method calls

Capturing and retrieving static calls allows for asserting that a method has been called and with which arguments.

Capture and retrieve public and protected property hook calls

Capturing and retrieving calls allows for asserting that a method has been called and with which arguments.


All versions of php-object-seam with dependencies

PHP Build Version
Package Version
Requires php Version >=7.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 robvanaarle/php-object-seam contains the following files

Loading the files please wait ...