sweetchuck / cdd
Circular dependency detector
Installs: 264 252
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 3
Forks: 0
Open Issues: 1
Requires
- php: >=7.2
Requires (Dev)
- ext-json: *
- phpunit/phpunit: ^8.0
- squizlabs/php_codesniffer: ^3.3
- sweetchuck/git-hooks: ^0.0
- sweetchuck/robo-git: ^0.2
- sweetchuck/robo-phpcs: ^0.1
- sweetchuck/robo-phpmd: ^0.1
This package is auto-updated.
Last update: 2024-11-07 20:14:45 UTC
README
Install
composer require sweetchuck/cdd
Usage
<?php declare(strict_types = 1); use Sweetchuck\cdd\CircularDependencyDetector; $detector = new CircularDependencyDetector(); $items = [ // Item "a" has no any dependencies. 'a' => [], // Item "b" depends on "c" and "d". 'b' => ['c', 'd'], // Item "c" has no any dependencies. 'c' => [], // Item "d" has no any dependencies. 'd' => [], ]; $loops = $detector->detect($items); /** * $loops = []; */ var_dump($loops); $items = [ // Item "a" depends on "b". 'a' => ['b'], // Item "b" depends on "a". 'b' => ['a'], ]; $loops = $detector->detect($items); /** * $loops = [ * 'a|b' => ['b', 'a', 'b'], * ]; */ var_dump($loops); $items = [ // Item "a" depends on "b". 'a' => ['b'], // Item "b" depends on "c". 'b' => ['c'], // Item "c" depends on "a". 'c' => ['a'], ]; $loops = $detector->detect($items); /** * $loops = [ * 'a|b|c' => ['c', 'a', 'b', 'c'], * ]; */ var_dump($loops);