Skip to content
This repository was archived by the owner on Nov 28, 2022. It is now read-only.
This repository was archived by the owner on Nov 28, 2022. It is now read-only.

Support wildcard dependency checks #27

@marc-mabe

Description

@marc-mabe

Hi,

This is a feature request to be able to support dependency checks via wildcards.

Something like this:

$phpArch->validate(new ForbiddenDependency('App\\Bus\\*\\Command', 'App\\Bus\\*\\Command'));
$phpArch->validate(new ForbiddenDependency('App\\Bus\\*\\Query', 'App\\Bus\\*\\Command'));

##Background:
I have a command/event/query bus implementation for business logic separated by business domain.
I would like to forbid commands to trigger other commands es this should be done via events.

##Example:
Wrong:

class XCommandHandler implements CommandHandler {
    public function handle(XCommand $command); void
    {
        // do whatever needs to be done

        $this->commandBus->dispatch(new OtherCommand());
    }
}

class OtherCommandHandler implements CommandHandler {
    public function handle(OtherCommand $command); void
    {
        // do whatever needs to be done
    }
}

Correct:

class XCommandHandler implements CommandHandler {
    public function handle(XCommand $command); void
    {
        // do whatever needs to be done

        $this->eventBus->dispatch(new XSucceededEvent());
    }
}

class OnXSucceededTriggerOther implements EventHandler {
    public function handle(XSucceededEvent $event); void
    {
        // do whatever needs to be done

        $this->commandBus->dispatch(new OtherCommand());
    }
}

class OtherCommandHandler implements CommandHandler {
    public function handle(OtherCommand $command); void
    {
        // do whatever needs to be done
    }
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions