Help us improve
Share bugs, ideas, or general feedback.
From acc
Analyzes PHP code for encapsulation violations like public mutable state, getter/setter abuse, Tell Don't Ask breaches, exposed internals, and anemic domain models. Reviews domain entities and aggregates.
npx claudepluginhub dykyi-roman/awesome-claude-code --plugin accHow this skill is triggered — by the user, by Claude, or both
Slash command
/acc:check-encapsulationThe summary Claude sees in its skill listing — used to decide when to auto-load this skill
This skill analyzes PHP codebases for encapsulation violations — situations where internal state is exposed, getters/setters replace behavior, or the "Tell, Don't Ask" principle is violated.
Detects code smells in PHP codebases including God Class, Feature Envy, Data Clumps, Long Parameter List, Long Method, Primitive Obsession, Message Chains, and Inappropriate Intimacy. Generates reports with severity levels and refactoring recommendations.
Identify code smells like long methods, duplication, low cohesion, and high coupling. Use when assessing code health.
Reviews object-oriented code for SOLID principles, DRY violations, composition vs inheritance choices, and Gang of Four design pattern applicability. Use when evaluating new or modified OO designs.
Share bugs, ideas, or general feedback.
This skill analyzes PHP codebases for encapsulation violations — situations where internal state is exposed, getters/setters replace behavior, or the "Tell, Don't Ask" principle is violated.
| Principle | Description | Violation Indicator |
|---|---|---|
| Information Hiding | Internal state not exposed | Public properties, many getters |
| Tell Don't Ask | Objects perform actions, not expose data | Getter chains, external decisions |
| Behavioral Richness | Objects have behavior, not just data | Anemic domain model |
| Invariant Protection | State changes validate constraints | Public setters without validation |
| ID | Pattern | Grep Target |
|---|---|---|
| ENC-01 | Public mutable props | public string|public int|public array in Domain (exclude readonly) |
| ENC-02 | Setter methods | public function set[A-Z] in Entity/Aggregate |
| ENC-03 | Getter chains | ->get[A-Z].*->get[A-Z].*->get[A-Z] |
| ENC-04 | External conditionals | if \(\$.*->get[A-Z].*=== |
| ENC-05 | Switch on state | switch \(\$.*->get[A-Z]|match \(\$.*->get[A-Z] |
| ENC-06 | Collection return | public function get.*\(\): array in Entity |
| ENC-07 | Doctrine exposure | public function get.*\(\): Collection in Domain |
| ENC-08 | Reflection access | ReflectionClass|ReflectionProperty|setAccessible |
| ENC-09 | Debug exposure | public function toArray\(\)|dump\(\)|debug\(\) in Domain |
| ENC-10 | Complex construction | new [A-Z].*Entity\(|new [A-Z].*Aggregate\( in Application |
| Issue | Severity |
|---|---|
| Public mutable state in Entity | Critical |
| Collection mutated externally | Critical |
| Anemic entity (ratio > 5.0) | Critical |
| Tell Don't Ask violation | Major |
| Getter chain (3+ levels) | Major |
| Internal array returned | Major |
| Setter in Aggregate | Minor |
| Reflection in non-test code | Minor |
# Encapsulation Analysis Report
## Summary
| Issue Type | Critical | Warning | Info |
|------------|----------|---------|------|
| Public Mutable State | N | N | - |
| Getter/Setter Abuse | N | N | N |
| Tell Don't Ask | N | N | - |
| Collection Exposure | N | N | - |
| Exposed Internals | N | N | N |
**Encapsulation Score: X%**
## Findings
### [ID]: [Title]
- **File:** `path:line`
- **Issue:** [Description]
- **Code:** [Problematic snippet]
- **Expected:** [Correct pattern]
- **Skills:** [Related generator skills]
## Getter/Behavior Ratio
| Entity | Getters | Setters | Behavior | Ratio | Status |
|--------|---------|---------|----------|-------|--------|
**Target:** Ratio < 2.0
## Refactoring Recommendations
### Immediate
1. Make all entity properties private
2. Replace setters with behavior methods
3. Return collection copies, not references
### Short-term
4. Extract Value Objects for validated data
5. Add factory methods for complex construction
6. Remove getter chains (add shortcut methods)
### Long-term
7. Review anemic entities for missing behavior
8. Consider CQRS to separate read/write models
Works with:
detect-code-smells — Feature Envy, Anemic Modelstructural-auditor — DDD compliancecreate-entity — Generate rich entitiescreate-value-object — Encapsulated value typesreferences/patterns.md — detailed detection patterns with code examples, report format samples, metrics examples, and rich entity template