PHPackages                             vashkatsi/php-duck-typing - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vashkatsi/php-duck-typing

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vashkatsi/php-duck-typing
=========================

A PHP library for asserting duck typing.

10PHP

Since Oct 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/Vashkatsi/php-duck-typing)[ Packagist](https://packagist.org/packages/vashkatsi/php-duck-typing)[ RSS](/packages/vashkatsi-php-duck-typing/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependenciesVersions (1)Used By (0)

DuckType
========

[](#ducktype)

A PHP library for asserting duck typing and structural type compliance.

Introduction
------------

[](#introduction)

**DuckType** allows you to check whether an object conforms to a specific structure (methods and properties) defined by an interface or class, without requiring the object to explicitly implement that interface or extend that class. This is useful in scenarios where you want to ensure that an object can be used in a particular context based on its available methods and properties, embracing the concept of duck typing:

> "If it looks like a duck and quacks like a duck, it's a duck."

Installation
------------

[](#installation)

Install the package via Composer:

```
composer require vashkatsi/ducktype
```

Usage
-----

[](#usage)

### Basic Example

[](#basic-example)

```
