| 1 | package PlantUML::ClassDiagram::Relation; | ||||||||||||||||||||||||||||||||
| 2 | |||||||||||||||||||||||||||||||||
| 3 | 3 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | 3 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 5 | 3 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 6 | |||||||||||||||||||||||||||||||||
| 7 | 3 | ▶ | use parent qw/Class::Accessor::Fast/; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 8 | 3 | __PACKAGE__->follow_best_practice; | |||||||||||||||||||||||||||||||
| 9 | |||||||||||||||||||||||||||||||||
| 10 | 3 | my @self_valiables = qw/ | |||||||||||||||||||||||||||||||
| 11 | name | ||||||||||||||||||||||||||||||||
| 12 | from | ||||||||||||||||||||||||||||||||
| 13 | to | ||||||||||||||||||||||||||||||||
| 14 | /; | ||||||||||||||||||||||||||||||||
| 15 | 3 | __PACKAGE__->mk_ro_accessors(@self_valiables); | |||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||
| 17 | 3 | my $symbol_name_map = +{ | |||||||||||||||||||||||||||||||
| 18 | '<-' => 'association', | ||||||||||||||||||||||||||||||||
| 19 | '->' => 'association', | ||||||||||||||||||||||||||||||||
| 20 | '<|-' => 'generalization', | ||||||||||||||||||||||||||||||||
| 21 | '-|>' => 'generalization', | ||||||||||||||||||||||||||||||||
| 22 | '<|.' => 'realization', | ||||||||||||||||||||||||||||||||
| 23 | '.|>' => 'realization', | ||||||||||||||||||||||||||||||||
| 24 | 'o-' => 'aggregation', | ||||||||||||||||||||||||||||||||
| 25 | '-o' => 'aggregation', | ||||||||||||||||||||||||||||||||
| 26 | '*-' => 'composite', | ||||||||||||||||||||||||||||||||
| 27 | '-*' => 'composite', | ||||||||||||||||||||||||||||||||
| 28 | }; | ||||||||||||||||||||||||||||||||
| 29 | |||||||||||||||||||||||||||||||||
| 30 | 3 | my $symbol_is_from_right_side = +{ | |||||||||||||||||||||||||||||||
| 31 | '<-' => 1, | ||||||||||||||||||||||||||||||||
| 32 | '<|-' => 1, | ||||||||||||||||||||||||||||||||
| 33 | '<|.' => 1, | ||||||||||||||||||||||||||||||||
| 34 | 'o-' => 1, | ||||||||||||||||||||||||||||||||
| 35 | '*-' => 1, | ||||||||||||||||||||||||||||||||
| 36 | '-|>' => 0, | ||||||||||||||||||||||||||||||||
| 37 | '->' => 0, | ||||||||||||||||||||||||||||||||
| 38 | '.|>' => 0, | ||||||||||||||||||||||||||||||||
| 39 | '-o' => 0, | ||||||||||||||||||||||||||||||||
| 40 | '-*' => 0, | ||||||||||||||||||||||||||||||||
| 41 | }; | ||||||||||||||||||||||||||||||||
| 42 | |||||||||||||||||||||||||||||||||
| 43 | 11 | ▶ | sub new { | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=4 SCAR=15.2
Pod
documented
| |||||||||||||||||||||||||||||||||
| 44 | 11 | my ($class, $name, $from, $to) = @_; | |||||||||||||||||||||||||||||||
| 45 | 11 | ▶ | my $attr = +{ | ||||||||||||||||||||||||||||||
|
Condition50%3/6
$name || ''
$from || ''
$to || ''
MC/DC0%0/1
$name || ''
$name
MC/DC0%0/1
$from || ''
$from
MC/DC0%0/1
$to || ''
$to
Truth table50%1/2
A
A= $name
Truth table50%1/2
A
A= $from
Truth table50%1/2
A
A= $to
| |||||||||||||||||||||||||||||||||
| 46 | name => $name || '', | ||||||||||||||||||||||||||||||||
| 47 | from => $from || '', | ||||||||||||||||||||||||||||||||
| 48 | to => $to || '', | ||||||||||||||||||||||||||||||||
| 49 | }; | ||||||||||||||||||||||||||||||||
| 50 | 11 | return $class->SUPER::new($attr); | |||||||||||||||||||||||||||||||
| 51 | } | ||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||
| 53 | 11 | ▶ | sub build { | ||||||||||||||||||||||||||||||
|
Subroutine
build: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||||||||||||||
| 54 | 11 | my ($class, $string) = @_; | |||||||||||||||||||||||||||||||
| 55 | |||||||||||||||||||||||||||||||||
| 56 | 11 | my ($symbol, $left, $right); | |||||||||||||||||||||||||||||||
| 57 | 11 | $string =~ /([\w|:]+)\s+(.+?)\s+([\w|:]+)/; | |||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | 11 | $left = $1; | |||||||||||||||||||||||||||||||
| 60 | 11 | $symbol = $2; | |||||||||||||||||||||||||||||||
| 61 | 11 | $right = $3; | |||||||||||||||||||||||||||||||
| 62 | |||||||||||||||||||||||||||||||||
| 63 | 11 | my $name = $class->_get_symbol_name($symbol); | |||||||||||||||||||||||||||||||
| 64 | 11 | my ($from, $to) = $class->_get_from_and_to($symbol, $left, $right); | |||||||||||||||||||||||||||||||
| 65 | |||||||||||||||||||||||||||||||||
| 66 | 11 | return $class->new($name, $from, $to); | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | 11 | ▶ | sub _get_symbol_name { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_symbol_name: called CC=3 SCAR=11.1
| |||||||||||||||||||||||||||||||||
| 70 | 11 | my ($class, $symbol) = @_; | |||||||||||||||||||||||||||||||
| 71 | 11 | for my $pattern (keys %$symbol_name_map){ | |||||||||||||||||||||||||||||||
| 72 | 61 | my $escaped_pattern = quotemeta($pattern); | |||||||||||||||||||||||||||||||
| 73 | 61 | ▶ | return $symbol_name_map->{$pattern} if $symbol =~ /$escaped_pattern/; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 74 | } | ||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||
| 76 | 0 | return undef; | |||||||||||||||||||||||||||||||
| 77 | } | ||||||||||||||||||||||||||||||||
| 78 | |||||||||||||||||||||||||||||||||
| 79 | # return (from, to) | ||||||||||||||||||||||||||||||||
| 80 | 11 | ▶ | sub _get_from_and_to { | ||||||||||||||||||||||||||||||
|
Subroutine
_get_from_and_to: called CC=4 SCAR=13.9
| |||||||||||||||||||||||||||||||||
| 81 | 11 | my ($class, $symbol, $left, $right) = @_; | |||||||||||||||||||||||||||||||
| 82 | |||||||||||||||||||||||||||||||||
| 83 | 11 | for my $pattern (keys %$symbol_is_from_right_side){ | |||||||||||||||||||||||||||||||
| 84 | 62 | my $escaped_pattern = quotemeta($pattern); | |||||||||||||||||||||||||||||||
| 85 | 62 | ▶ | if ($symbol =~ /$escaped_pattern/) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 86 | |||||||||||||||||||||||||||||||||
| 87 | 11 | ▶ | return ($right, $left) if $symbol_is_from_right_side->{$pattern}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 88 | 4 | return ($left, $right); | |||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||
| 90 | } | ||||||||||||||||||||||||||||||||
| 91 | |||||||||||||||||||||||||||||||||
| 92 | 0 | return ($left, $right); | |||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | 3 | 1; | |||||||||||||||||||||||||||||||