phpcdm
1.0.0
phpcdm 은 PHP의 코드 밀도 측정기입니다
이 코드를보십시오.
<?php
final class SomethingGreat
{
public function doSomethingGreat ( $ entity , $ property , $ type , $ refProperties , $ update , $ delete )
{
$ time = $ this -> startAction ( " $ type ( " . implode ( ' , ' , ( array ) $ type ) . ' ) ' );
$ this -> createAction ()-> addExtraKey ( $ entity , $ entity , $ property , $ refProperties , $ delete , $ update )-> execute ();
$ this -> finishAction ( $ time );
$ this -> createAction ()-> updateProperty ( $ entity , $ property , $ type )-> execute ();
if ( $ type instanceof InvalidArgumentException && $ type -> getMessage () !== null ) {
$ this -> createAction ()-> addDescriptionOnProperty ( $ entity , $ property , $ type -> description )-> execute ();
}
$ this -> createAction ()-> renameEntity ( $ entity , $ property )-> execute ();
$ this -> finishAction ( $ time );
$ time = $ this -> startAction ( " $ type ( " . implode ( ' , ' , ( array ) $ type ) . ' ) ' );
$ this -> createAction ()-> addExtraKey ( $ entity , $ entity , $ property , $ refProperties , $ delete , $ update )-> execute ();
if ( $ type instanceof InvalidArgumentException && $ type -> getMessage () !== $ delete ) {
$ this -> finishAction ( $ time );
$ this -> createAction ()-> addDescriptionOnProperty ( $ entity , $ property , $ type -> description )-> execute ();
$ this -> createAction ()-> renameEntity ( $ entity , $ property )-> execute ();
}
$ this -> createAction ()-> updateProperty ( $ entity , $ property , $ type )-> execute ();
$ this -> finishAction ( $ time );
}
}캐릭터의 벽처럼 보입니다. 실제로 캐릭터의 벽 입니다 . 아무도이 코드의 저자가 의미하는 바를 쉽게 이해할 수 없으며, 아무도 그것을 읽으려고 행복하지 않을 것입니다. 더욱이, 종종 그러한 캐릭터 벽은 나쁜 응용 프로그램 디자인의 결과입니다.
코드 밀도는 단일 페이지에 얼마나 많은 문자가 표시되는지를 측정하는 것입니다.
PHP 코드 밀도 미터는 개발자가 코드 밀도 문제를 방지하고 결국 응용 프로그램을 양호한 모양으로 유지하는 것을 목표로합니다.
예제 코드의 밀도는 0.381이며, 이는 기본 임계 값 (0.2)보다 훨씬 높습니다.
이 도구를 작곡가를 사용하여 프로젝트에 로컬, 프로젝트 당 개발 시간 종속성으로 추가 할 수 있습니다.
composer require --dev vantoozz/phpcdm또한 PHPCDM은 다음과 같이 전 세계적으로 설치 될 수 있습니다.
composer global require --dev vantoozz/phpcdm src 디렉토리 분석
./vendor/bin/phpcdm src오류 코드로 종료
./vendor/bin/phpcdm src --non-zero-exit-on-violation