phpexperts/phploc-analyzer

一种简单地将phploc统计数据集成到您程序中的方法。

v1.1.1 2020-11-01 10:03 UTC

This package is auto-updated.

Last update: 2024-08-29 05:07:27 UTC


README

TravisCI Test Coverage

我制作了这个项目的创建时间轴,直到v1.0.0。 您可以在https://www.youtube.com/watch?v=BlYdIxj_A6A观看

PHPLOCAnalyzer是PHP Experts, Inc.的一个项目,旨在自动化sebastianbergmann/phploc的报告。

它将这个

Size
  Lines of Code (LOC)                              687
  Comment Lines of Code (CLOC)                     143 (20.82%)
  Non-Comment Lines of Code (NCLOC)                544 (79.18%)
  Logical Lines of Code (LLOC)                     188 (27.37%)
    Classes                                        168 (89.36%)
      Average Class Length                          42
        Minimum Class Length                        10
        Maximum Class Length                        94
      Average Method Length                          3
        Minimum Method Length                        0
        Maximum Method Length                       11
    Functions                                        0 (0.00%)
      Average Function Length                        0
    Not in classes or functions                     20 (10.64%)

Cyclomatic Complexity
  Average Complexity per LLOC                     0.42
  Average Complexity per Class                   20.75
    Minimum Class Complexity                      1.00
    Maximum Class Complexity                     44.00
  Average Complexity per Method                   3.06
    Minimum Method Complexity                     1.00
    Maximum Method Complexity                    15.00

Dependencies
  Global Accesses                                    0
    Global Constants                                 0 (0.00%)
    Global Variables                                 0 (0.00%)
    Super-Global Variables                           0 (0.00%)
  Attribute Accesses                                55
    Non-Static                                      55 (100.00%)
    Static                                           0 (0.00%)
  Method Calls                                      47
    Non-Static                                      41 (87.23%)
    Static                                           6 (12.77%)

Structure
  Namespaces                                         1
  Interfaces                                         1
  Traits                                             1
  Classes                                            2
    Abstract Classes                                 2 (100.00%)
    Concrete Classes                                 0 (0.00%)
  Methods                                           46
    Scope
      Non-Static Methods                            46 (100.00%)
      Static Methods                                 0 (0.00%)
    Visibility
      Public Methods                                30 (65.22%)
      Non-Public Methods                            16 (34.78%)
  Functions                                          2
    Named Functions                                  0 (0.00%)
    Anonymous Functions                              2 (100.00%)
  Constants                                          3
    Global Constants                                 0 (0.00%)
    Class Constants                                  3 (100.00%)

转换成这个

{
    "directories": 2,
    "files": 12,
    "size": {
        "loc": 1870,
        "loc_comments": 383,
        "loc_noncomment": 1487,
        "loc_logical": 454,
        "loc_global_scope": 67,
        "classes": 385,
        "class_length_avg": 32,
        "class_length_min": 1,
        "class_length_max": 94,
        "method_length_avg": 4,
        "method_length_min": 0,
        "method_length_max": 17,
        "functions": 2,
        "function_length_avg": 0
    },
    "cyclomatic": {
        "lloc": 0.22,
        "class_avg": 9.33,
        "class_min": 1,
        "class_max": 44,
        "method_avg": 2.1,
        "method_min": 1,
        "method_max": 15
    },
    "dependencies": {
        "global_constants": 0,
        "global_variables": 0,
        "super_globals": 0,
        "attributes_nonstatic": 85,
        "attributes_static": 0,
        "methodcalls_nonstatic": 128,
        "methodcalls_static": 73
    },
    "structure": {
        "namespaces": 3,
        "interfaces": 1,
        "traits": 1,
        "classes_abstract": 2,
        "classes_concrete": 8,
        "methods_scope_nonstatic": 95,
        "methods_scope_static": 0,
        "visibility_public": 72,
        "visibility_nonpublic": 23,
        "functions_named": 0,
        "functions_anonymous": 3,
        "constants_global": 0,
        "constants_class": 3
    }
}

安装

通过Composer

composer require phpexperts/phploc-analyzer

用法

use \PHPExperts\PHPLOCAnalyzer\PHPLOCAnalyzer;
$phplocDTO = PHPLOCAnalyzer::analyze('/code/path');
echo json_encode($phplocDTO, JSON_PRETTY_PRINT);

测试

phpunit --testdox

贡献者

Theodore R. Smith theodore@phpexperts.pro
GPG指纹:4BF8 2613 1C34 87AC D28F 2AD8 EB24 A91D D612 5690
CEO:PHP Experts, Inc.

许可证

MIT许可证。有关更多信息,请参阅许可证文件