Commit e4f33d7
committed
refactor: split ZammadClient into three concerns (ClientFactory, ImpersonationHandler, slim client)
Split the monolithic ZammadClient into focused classes:
- ClientFactory → GuzzleClientFactory implements ClientFactoryInterface
Guzzle wiring lives exclusively in GuzzleClientFactory::buildClient()
Non-Guzzle via new ZammadClient(new RequestHandler(...))
- ImpersonationHandler — stateless decorator implementing
RequestHandlerInterface. Injects From header on every request
including getRaw(). No shared mutable state.
- ZammadClient — slimmed from ~210 to ~79 lines. Only repo() and
getHandler(). Repository access via typed, explicit, IDE-friendly
methods (ticket(), user(), group(), etc.) implemented directly on
the class.
Removals and cleanups:
- __call, aliasMap, resolveAlias — replaced by explicit typed methods
- RequestHandler:: — shared mutable state removed
- RequestHandlerInterface::setOnBehalfOfUser/getOnBehalfOfUser — removed
- RequestHandlerInterface::getRaw() extended with $headers parameter
for ImpersonationHandler compatibility
- onBehalfOf() / performOnBehalfOf() — not a Client concern;
use new ZammadClient(new ImpersonationHandler($handler, $userId))
- getListKey() default $this->resourcePath; 10 identical impls removed
Namespace structure:
Core/Contracts/ — ClientInterface, ClientFactoryInterface
Core/Repository/ — AbstractRepository, RepositoryRegistry, PaginatedList, Resource, ResponseParser, DtoHydrator
Core/Transport/ — RequestHandler, RetryAfterMiddleware, ImpersonationHandler, HttpPageFetcher
Core/Traits/ — RepositoryAccessors (opt-in for custom ClientInterface impls), HasTimestamps, HydratesFromArray, SerializesToArray
Factory/ — GuzzleClientFactory
Bug fixes:
- HttpPageFetcher::extractIndexResults() now reads total_count from
API response instead of hard-coding null1 parent 83c29f2 commit e4f33d7
53 files changed
Lines changed: 656 additions & 1189 deletions
File tree
- .opencode/plans
- examples
- src
- Bridge
- Core
- Contracts
- Repository
- Traits
- Transport
- Endpoints
- Groups
- Links
- Organizations
- Tags
- TextModules
- TicketArticles
- TicketPriorities
- TicketStates
- Tickets
- Users
- Exceptions
- Factory
- test
- Integration/Traits
- Unit
- Core
- Traits
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2 | 2 | | |
3 | 3 | | |
4 | 4 | | |
| 5 | + | |
| 6 | + | |
0 commit comments