php 图论,Mondrian - 使用图论的php代码静态分析工具

Mondrian c4c4dd0f1416267e31d85e7f7652f8ff.png

Ok guyz, you have a master degree in Graph Theory, you follow Law of Demeter and you live on S.O.L.I.D principles ?

Let's have some Fun ! (^ω^)

What

It is a set of CLI tools to help you to analyse and refactor highly coupled classes. As you know Law of Demeter and S.O.L.I.D guidances, you need your classes loosely coupled. And for this, there is one only rule : ABSTRACTION

20cefbb06419c29642571797b60f77e4.png

This app provides some helpers to add abstraction into concrete classes with minimum pain.

Getting started

Download the PHAR : mondrian.phar

Try to run a simple command with a few files (or a small part of a project)

$ mondrian.phar digraph /home/dev/project

This command produces a DOT file for GraphViz. Other formats are available :

html : interactive graph with the d3.js awesome library

svg : open standard for vector graphics (requires GraphViz)

json : format for d3.js for example

Example with html format

$ php mondrian.php d --ignore=tests --ignore=vendor --format=html ./MyPhpProject/

cb1b33dc816082e3a8bebf8f400e924c.png

Note: The generated html file does not require any dependencies nor a connection.

Ecosystem

Running unit tests with PHPUnit

$ phpunit.phar

Building the documentation with phpDocumentor

$ phpDocumentor.phar

Building mondrian.phar from the sources with box2

$ box.phar b

Examples

Default digraph on trismegiste/dokudoki

sample1.jpg

Which components are bottleneck ?

sample2.jpg

Reduced graph to LSP violations on trismegiste/prolog

sample3.jpg

How

Read the concept here

Read the online documentation here

And the API here (not up to date)

Extensible

You can easily add plugins to this tool to make your own algorithm, coloring scheme or new generator. I try to make the API mostly decoupled, re-usable and with great SRP and OCP concerns. Look into the "About" plugin to understand a basic stub of plugin.

Third party

Packages used in this project :

symfony/console for creating CLI app with swag

alom/graphviz for rendering DOT files

symfony/finder for searching files through filesystem

symfony/config for managing yaml configuration without headache

D3.js for graph rendering in html

Phar builded with Box

Special thanks

William Gibson

JS Bach

Dream Theater

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值