PHPackages                             sebastianknott/hamcrest-object-accessor - 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. sebastianknott/hamcrest-object-accessor

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

sebastianknott/hamcrest-object-accessor
=======================================

Adds a Matcher to Hamcrest which can access properties and methods of objects.

4.0.1(4mo ago)0278.2k↓26.5%13GPL-3.0-or-laterPHPPHP ^8.3CI failing

Since Sep 29Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/sebastianknott/hamcrestObjectAccessor)[ Packagist](https://packagist.org/packages/sebastianknott/hamcrest-object-accessor)[ RSS](/packages/sebastianknott-hamcrest-object-accessor/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (7)Dependencies (9)Versions (8)Used By (3)

[![Build Status](https://camo.githubusercontent.com/fe0b64f87d517f787658dbe93c3a57e5e00165a187113245355850641c7079d6/68747470733a2f2f7777772e7472617669732d63692e6f72672f646f6f6d68616d6d65726368656e2f68616d63726573744f626a6563744163636573736f722e7376673f6272616e63683d6d6173746572)](https://www.travis-ci.org/doomhammerchen/hamcrestObjectAccessor)

Hamcrest Object Accessor
========================

[](#hamcrest-object-accessor)

This package extends the collection of matchers in [Hamcrest](https://github.com/hamcrest/hamcrest-php). For general informationan about [Hamcrest](https://github.com/hamcrest/hamcrest-php)please visit their website. It's worth it ^^.

hasProperty
-----------

[](#hasproperty)

This Matcher tries to access a property of an object by name. It uses Getters, public properties, hassers and issers.

### Example Class

[](#example-class)

```
class HasPropertyFixture
{
    public $bla = 'blub';
    private $getable = 'blub';
    private $issable = true;
    private $hassable = true;
    private $notGettable = 'nope';

    public function getGetable()
    {
        return $this->getable;
    }

    public function isIssable()
    {
        return $this->issable;
    }

    public function hasHassable()
    {
        return $this->hassable;
    }
}
```

### Matcher

[](#matcher)

```
$object = new hasPropertyFixture();
MatcherAssert::assertThat(
    $object,
    hasProperty(
        'bla', // property name
        stringValue() // matcher the property value has to match
    )
);

MatcherAssert::assertThat(
    $object,
    hasProperty(
        'Getable',
        stringValue()
    )
);

MatcherAssert::assertThat(
    $object,
    hasProperty(
        'isIssable',
        boolValue()
    )
);
```

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

[](#installation)

You may include this package by composer.

`composer require --dev sebastianknott/hamcrest-object-accessor`

I recommend to use this matcher in dev environments only!

### Setup

[](#setup)

Once the Package is installed you can call the matcher staticly ...

`HasProperty::hasProperty('bla', stringValue()));`

... or by requiring `src/functions.php` provided by this package.

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance76

Regular maintenance activity

Popularity34

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~443 days

Recently: every ~616 days

Total

7

Last Release

129d ago

Major Versions

1.0.2 → 2.0.02020-10-06

2.0.0 → 3.0.02023-01-18

3.0.0 → 4.0.02025-03-16

PHP version history (4 changes)1.0PHP &gt;=5.6

2.0.0PHP &gt;=7.2

3.0.0PHP ^8.1

4.0.0PHP ^8.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/4c6fe88d259b4f88b5b40dc180b4674ece3e8b6dc7fcf4d417c537c86aed191f?d=identicon)[sebastianknott](/maintainers/sebastianknott)

---

Top Contributors

[![sebastianknott](https://avatars.githubusercontent.com/u/6544387?v=4)](https://github.com/sebastianknott "sebastianknott (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/sebastianknott-hamcrest-object-accessor/health.svg)

```
[![Health](https://phpackages.com/badges/sebastianknott-hamcrest-object-accessor/health.svg)](https://phpackages.com/packages/sebastianknott-hamcrest-object-accessor)
```

###  Alternatives

[winzou/state-machine

A very lightweight yet powerful PHP state machine

52113.7M18](/packages/winzou-state-machine)[hirethunk/verbs

An event sourcing package that feels nice.

513162.9k6](/packages/hirethunk-verbs)[cognesy/instructor-php

The complete AI toolkit for PHP: unified LLM API, structured outputs, agents, and coding agent control

310107.9k1](/packages/cognesy-instructor-php)[symfony/ai-platform

PHP library for interacting with AI platform provider.

51927.7k136](/packages/symfony-ai-platform)[solspace/craft-freeform

The most flexible and user-friendly form building plugin!

52664.9k12](/packages/solspace-craft-freeform)[codefog/contao-haste

haste extension for Contao Open Source CMS

42650.8k139](/packages/codefog-contao-haste)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
