Recommend this page to a friend! |
Download |
Info | Documentation | Files | Install with Composer | Download | Reputation | Support forum | Blog | Links |
Last Updated | Ratings | Unique User Downloads | Download Rankings | |||||
2024-11-03 (Yesterday) | Not yet rated by the users | Total: Not yet counted | Not yet ranked |
Version | License | PHP version | Categories | |||
php-class-dependenci 1.0 | The PHP License | 8 | Tools, Language, PHP 8 |
Description | Author | |
This package can analyze the dependencies of project classes. |
<p align="center"> <img src="https://github.com/DeGraciaMathieu/php-smelly-code-detector/blob/master/arts/robot.png" width="250"> </p>
> ?? For French developers, an article on Laravel France explores these stable dependency concepts.
This tool is distributed as a PHP Archive (PHAR):
wget https://github.com/DeGraciaMathieu/php-class-dependencies-analyzer/raw/main/builds/class-dependencies-analyzer
php class-dependencies-analyzer --version
Inevitably, in an object-oriented project, classes will depend on each other.
These dependencies generate instability that can be measured with the following formula:
Instability = Efferent / (Afferent + Efferent)
Afferent coupling represents the number of components that depend on a given component, while efferent coupling counts the number of dependencies a given component has.
<img src='https://cdn.laravel-france.com/images/pictures/6aa50c00-414c-4817-928d-c67d1bf996e0.png'>
Instability ranges between 0 and 1, where 0 represents a fully stable class and 1 represents a fully unstable class.
Stable class has few dependencies but is depended on by many components. Therefore, a stable class is critical to the project and must be reliable and well-tested.
An unstable class has many dependencies but few components depend on it. Therefore, it?s easier to modify, but it?s more likely to be affected by changes in its dependencies. It is recommended to monitor the dependencies of an unstable component and replace those that are even more unstable with an abstraction.
It?s important to manage these dependencies between classes to maintain maintainable, modular, and easily testable code.
This tool allows you to:
To visualize the instability and coupling of your classes:
php class-dependencies-analyzer analyze ./path/to/project
?? To obtain accurate results, it is important to analyze your entire codebase, use the --only=*
or --exclude=*
options to filter the results.
php class-dependencies-analyzer analyze app --only=App\\Domain,Infrastructure
php class-dependencies-analyzer analyze app --exclude=Models
For visualizing the results in a graph, you can use the --graph
option:
php class-dependencies-analyzer analyze app --only=App\\Domain --graph
<img style="width: 50%;" src='/arts/graph.png'>
A dependency cycle is a class that depends on itself through its dependencies.
<img src='https://cdn.laravel-france.com/images/pictures/34ddeac2-d9ac-4ebb-a54c-48f7940945ca.png'>
This violates the acyclic dependencies principle, it can be a sign of a bad design and reveal an ensemble of components difficult to maintain and evolve.
php class-dependencies-analyzer cyclic ./path/to/project
> You can filter the results using the --only=*
or --exclude=*
options.
A fragile dependancy is a class that depends on a class that is more unstable than it.
It can be a sign of a bad design and an indicator of a class that can suffer from side effects of its dependencies.
The first class will be sensitive to any changes made to the second class and will experience side effects.
<img src='https://cdn.laravel-france.com/images/pictures/c80b59f3-ffad-4609-9364-f8efa4e62c9a.png'>
These dependencies can generate bugs and difficulties in evolution.
php class-dependencies-analyzer weakness ./path/to/project
To filter results based on an instability delta, you can use the --min-delta
option.
php class-dependencies-analyzer weakness ./path/to/project --min-delta=0.1
The delta corresponds to the difference in stability between a class and one of its dependencies. The greater this difference, the more likely the first component is to suffer from side effects caused by its unstable dependency.
> You can filter the results using the --only=*
or --exclude=*
options.
> [!TIP] > Other analysis tools are available.
Files (112) |
File | Role | Description | ||
---|---|---|---|---|
.github (1 directory) | ||||
app (5 directories) | ||||
arts (1 file) | ||||
bootstrap (2 files) | ||||
config (3 files) | ||||
resources (1 directory) | ||||
tests (3 files, 3 directories) | ||||
.editorconfig | Data | Auxiliary data | ||
box.json | Data | Auxiliary data | ||
class-dependencies-analyzer | Class | Class source | ||
composer.json | Data | Auxiliary data | ||
composer.lock | Data | Auxiliary data | ||
phpunit.xml.dist | Data | Auxiliary data | ||
README.md | Doc. | Documentation |
Files (112) | / | .github | / | workflows |
File | Role | Description |
---|---|---|
build.yml | Data | Auxiliary data |
testing.yml | Data | Auxiliary data |
Files (112) | / | app |
File | Role | Description | ||
---|---|---|---|---|
Application (3 directories) | ||||
Domain (5 directories) | ||||
Infrastructure (2 directories) | ||||
Presenter (1 directory) | ||||
Providers (1 file, 1 directory) |
Files (112) | / | app | / | Application |
Files (112) | / | app | / | Application | / | Analyze |
File | Role | Description |
---|---|---|
AnalyzeAction.php | Class | Class source |
AnalyzePresenter.php | Class | Class source |
AnalyzeRequest.php | Class | Class source |
AnalyzeResponse.php | Class | Class source |
AnalyzeResponseMapper.php | Class | Class source |
ResponseMapper.php | Class | Class source |
Files (112) | / | app | / | Application | / | Cyclic |
File | Role | Description |
---|---|---|
CyclicAction.php | Class | Class source |
CyclicPresenter.php | Class | Class source |
CyclicRequest.php | Class | Class source |
CyclicResponse.php | Class | Class source |
CyclicResponseMapper.php | Class | Class source |
Files (112) | / | app | / | Application | / | Weakness |
File | Role | Description |
---|---|---|
WeaknessAction.php | Class | Class source |
WeaknessPresenter.php | Class | Class source |
WeaknessRequest.php | Class | Class source |
WeaknessResponse.php | Class | Class source |
WeaknessResponseMapper.php | Class | Class source |
Files (112) | / | app | / | Domain |
File | Role | Description | ||
---|---|---|---|---|
Aggregators (1 file) | ||||
Entities (1 file) | ||||
Ports (2 directories) | ||||
Services (4 files) | ||||
ValueObjects (3 files) |
Files (112) | / | app | / | Domain | / | Aggregators |
File | Role | Description |
---|---|---|
DependencyAggregator.php | Class | Class source |
Files (112) | / | app | / | Domain | / | Entities |
File | Role | Description |
---|---|---|
ClassDependencies.php | Class | Class source |
Files (112) | / | app | / | Domain | / | Ports | / | Aggregators |
File | Role | Description |
---|---|---|
FileAggregator.php | Class | Class source |
Files (112) | / | app | / | Domain | / | Ports | / | Repositories |
File | Role | Description |
---|---|---|
FileRepository.php | Class | Class source |
Files (112) | / | app | / | Domain | / | Services |
File | Role | Description |
---|---|---|
CyclicDependency.php | Class | Class source |
Instability.php | Class | Class source |
Stack.php | Class | Class source |
Visited.php | Class | Class source |
Files (112) | / | app | / | Domain | / | ValueObjects |
File | Role | Description |
---|---|---|
Coupling.php | Class | Class source |
Dependencies.php | Class | Class source |
Fqcn.php | Class | Class source |
Files (112) | / | app | / | Infrastructure |
Files (112) | / | app | / | Infrastructure | / | Analyze |
Files (112) | / | app | / | Infrastructure | / | Analyze | / | Adapters | / | Jerowork |
File | Role | Description |
---|---|---|
AnalyzerServiceAdapter.php | Class | Class source |
CustomClassDependenciesParser.php | Class | Class source |
NodeTraverserFactory.php | Class | Class source |
Files (112) | / | app | / | Infrastructure | / | Analyze | / | Ports |
File | Role | Description |
---|---|---|
AnalyzerService.php | Class | Class source |
Files (112) | / | app | / | Infrastructure | / | File |
Files (112) | / | app | / | Infrastructure | / | File | / | Adapters |
File | Role | Description | ||
---|---|---|---|---|
Aggregators (1 file) | ||||
DataTransferObjects (1 file) | ||||
Repositories (1 file) |
Files (112) | / | app | / | Infrastructure | / | File | / | Adapters | / | Aggregators |
File | Role | Description |
---|---|---|
FileAggregatorAdapter.php | Class | Class source |
Files (112) | / | app | / | Infrastructure | / | File | / | Adapters | / | DataTransferObjects |
File | Role | Description |
---|---|---|
FileAdapter.php | Class | Class source |
Files (112) | / | app | / | Infrastructure | / | File | / | Adapters | / | Repositories |
File | Role | Description |
---|---|---|
FileRepositoryAdapter.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze |
File | Role | Description | ||
---|---|---|---|---|
Filters (6 files) | ||||
Graph (6 files, 2 directories) | ||||
Summary (6 files) | ||||
AnalyzeCommand.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Filters |
File | Role | Description |
---|---|---|
Depth.php | Class | Class source |
Filter.php | Class | Class source |
FilterFactory.php | Class | Class source |
Metrics.php | Class | Class source |
NullFilter.php | Class | Class source |
TargetFilter.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Graph |
File | Role | Description | ||
---|---|---|---|---|
Adapters (1 directory) | ||||
Ports (2 files) | ||||
GraphEnums.php | Aux. | Configuration script | ||
GraphPresenter.php | Class | Class source | ||
GraphSettings.php | Class | Class source | ||
GraphSettingsFactory.php | Class | Class source | ||
GraphView.php | Class | Class source | ||
GraphViewModel.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Graph | / | Adapters |
File | Role | Description | ||
---|---|---|---|---|
Cytoscape (4 files) |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Graph | / | Adapters | / | Cytoscape |
File | Role | Description |
---|---|---|
CytoscapeGraph.php | Class | Class source |
CytoscapeGraphMapper.php | Class | Class source |
Edges.php | Class | Class source |
Nodes.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Graph | / | Ports |
File | Role | Description |
---|---|---|
Graph.php | Class | Class source |
GraphMapper.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Analyze | / | Summary |
File | Role | Description |
---|---|---|
SummaryMapper.php | Class | Class source |
SummaryPresenter.php | Class | Class source |
SummarySettings.php | Class | Class source |
SummarySettingsFactory.php | Class | Class source |
SummaryView.php | Class | Class source |
SummaryViewModel.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Cyclic |
File | Role | Description | ||
---|---|---|---|---|
Summary (7 files) | ||||
CyclicCommand.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Cyclic | / | Summary |
File | Role | Description |
---|---|---|
CycleHelper.php | Class | Class source |
CyclicPresenterMapper.php | Class | Class source |
SummaryPresenter.php | Class | Class source |
SummarySettings.php | Class | Class source |
SummarySettingsFactory.php | Class | Class source |
SummaryView.php | Class | Class source |
SummaryViewModel.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Weakness |
File | Role | Description | ||
---|---|---|---|---|
Summary (6 files) | ||||
WeaknessCommand.php | Class | Class source |
Files (112) | / | app | / | Presenter | / | Commands | / | Weakness | / | Summary |
File | Role | Description |
---|---|---|
SummaryPresenter.php | Class | Class source |
SummarySettings.php | Class | Class source |
SummarySettingsFactory.php | Class | Class source |
SummaryView.php | Class | Class source |
SummaryViewModel.php | Class | Class source |
WeaknessPresenterMapper.php | Class | Class source |
Files (112) | / | app | / | Providers |
File | Role | Description | ||
---|---|---|---|---|
Custom (1 file) | ||||
AppServiceProvider.php | Class | Class source |
Files (112) | / | app | / | Providers | / | Custom |
File | Role | Description |
---|---|---|
CustomNodeTraverserFactory.php | Class | Class source |
Files (112) | / | bootstrap |
File | Role | Description |
---|---|---|
app.php | Example | Example script |
providers.php | Class | Class source |
Files (112) | / | config |
File | Role | Description |
---|---|---|
app.php | Class | Class source |
commands.php | Class | Class source |
view.php | Aux. | Configuration script |
Files (112) | / | tests |
File | Role | Description | ||
---|---|---|---|---|
Builders (2 files) | ||||
Feature (1 file) | ||||
Unit (1 file, 6 directories) | ||||
CreatesApplication.php | Class | Class source | ||
Pest.php | Class | Class source | ||
TestCase.php | Class | Class source |
Files (112) | / | tests | / | Builders |
File | Role | Description |
---|---|---|
ClassDependenciesBuilder.php | Class | Class source |
DependencyAggregatorBuilder.php | Class | Class source |
Files (112) | / | tests | / | Feature |
File | Role | Description |
---|---|---|
InspireCommandTest.php | Aux. | Configuration script |
Files (112) | / | tests | / | Unit |
File | Role | Description | ||
---|---|---|---|---|
Aggregators (1 file) | ||||
Entities (1 file) | ||||
Formatters (2 files) | ||||
Helpers (1 file) | ||||
Services (2 files) | ||||
ValueObjects (2 files) | ||||
ExampleTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | Aggregators |
File | Role | Description |
---|---|---|
DependencyAggregatorTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | Entities |
File | Role | Description |
---|---|---|
ClassDependenciesTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | Formatters |
File | Role | Description |
---|---|---|
ArrayFormatterTest.php | Example | Example script |
NameFormatterTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | Helpers |
File | Role | Description |
---|---|---|
CycleHelperTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | Services |
File | Role | Description |
---|---|---|
CyclicDependencyTest.php | Class | Class source |
InstabilityTest.php | Example | Example script |
Files (112) | / | tests | / | Unit | / | ValueObjects |
File | Role | Description |
---|---|---|
CouplingTest.php | Example | Example script |
FqcnTest.php | Example | Example script |
The PHP Classes site has supported package installation using the Composer tool since 2013, as you may verify by reading this instructions page. |
Install with Composer |
php-class-dependenci-2024-11-03.zip 163KB | |
php-class-dependenci-2024-11-03.tar.gz | |
Install with Composer |
Version Control | Unique User Downloads | |||||||
100% |
|
Applications that use this package |
If you know an application of this package, send a message to the author to add a link here.