Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/sweetchuck/cdd

Circular dependency detector
https://github.com/sweetchuck/cdd

lint tree tree-structure validator

Last synced: 3 months ago
JSON representation

Circular dependency detector

Awesome Lists containing this project

README

        

# Circular dependency detector

[![CircleCI](https://circleci.com/gh/Sweetchuck/cdd/tree/2.x.svg?style=svg)](https://circleci.com/gh/Sweetchuck/cdd/?branch=2.x)
[![codecov](https://codecov.io/gh/Sweetchuck/cdd/branch/2.x/graph/badge.svg?token=HSF16OGPyr)](https://app.codecov.io/gh/Sweetchuck/cdd/branch/2.x)

## Install

composer require sweetchuck/cdd

## Usage

```php
[],

// 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);
```