Skip to content

Commit b2efaf5

Browse files
authored
Merge pull request #42 from smeghead/division-diagram
Division diagram
2 parents 97cb233 + 1c4397c commit b2efaf5

21 files changed

+231
-4
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,9 @@
11
# CHANGELOG
22

3+
### Features
4+
5+
* add division diagram option.
6+
37
### Bug fix
48

59
* Fixed so that unnamed external packages are not displayed in the package association diagram.

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FROM php:8.1-cli
22

3-
RUN apt-get update && apt-get install -y zip git plantuml && apt-get clean && rm -rf /var/lib/apt/lists/*
3+
RUN apt-get update && apt-get install -y zip git plantuml fonts-noto-cjk && apt-get clean && rm -rf /var/lib/apt/lists/*
44

55
COPY --from=composer:latest /usr/bin/composer /usr/bin/composer

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,13 @@ If it finds packages that depend on each other, it will warn you with a thick re
208208
![PlantUML output image.](output-package.png)
209209
210210
211+
### Division Diagram
212+
213+
If you are using the Enum added in PHP8.1, you can output the division chart.
214+
Visualizing the divisions used in the program can be useful for research and design.
215+
216+
![PlantUML output image.](output-division.png)
217+
211218
## Development
212219
213220
### Open shell

bin/php-class-diagram

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ $options = getopt('hv',[
1414
'version',
1515
'class-diagram',
1616
'package-diagram',
17+
'division-diagram',
1718
'jig-diagram',
1819
'enable-class-properties',
1920
'disable-class-properties',
@@ -37,6 +38,7 @@ OPTIONS
3738
-v, --version show version.
3839
--class-diagram output class diagram script. (default)
3940
--package-diagram output package diagram script.
41+
--division-diagram output division diagram script.
4042
--jig-diagram output class diagram and package diagram script.
4143
--enable-class-properties describe properties in class diagram. (default)
4244
--disable-class-properties not describe properties in class diagram.

dogfood-model.png

11.3 KB
Loading

dogfood-package.png

3.57 KB
Loading

dogfood.png

34.3 KB
Loading

output-division.png

24.4 KB
Loading

src/Config/Options.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ class Options
1515
const DIAGRAM_CLASS = 'class';
1616
const DIAGRAM_PACKAGE = 'package';
1717
const DIAGRAM_JIG = 'jig';
18+
const DIAGRAM_DIVSION = 'division';
1819

1920
public function __construct(array $opt)
2021
{
@@ -43,6 +44,9 @@ public function diagram(): string
4344
if (isset($this->opt['jig-diagram'])) {
4445
return self::DIAGRAM_JIG;
4546
}
47+
if (isset($this->opt['division-diagram'])) {
48+
return self::DIAGRAM_DIVSION;
49+
}
4650
// default
4751
return self::DIAGRAM_CLASS;
4852
}
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
<?php
2+
3+
declare(strict_types=1);
4+
5+
namespace Smeghead\PhpClassDiagram\DiagramElement\Division;
6+
7+
class DivisionColor {
8+
private static $gen;
9+
public static function nextColor(): string {
10+
if (empty(self::$gen)) {
11+
self::$gen = generateDivisionColorGenerator();
12+
}
13+
self::$gen->next();
14+
return self::$gen->current();
15+
}
16+
}
17+
18+
function generateDivisionColorGenerator(): \Generator
19+
{
20+
$COLORS = [
21+
'#ffffcc',
22+
'#ccffcc',
23+
'#ffcccc',
24+
'#ccccff',
25+
'#ccffff',
26+
'#ffccff',
27+
];
28+
while (true) {
29+
foreach ($COLORS as $c) {
30+
yield $c;
31+
}
32+
}
33+
}

0 commit comments

Comments
 (0)