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