| 1 | package Class::PObject::Type; | ||||||||||||||||||||
| 2 | |||||||||||||||||||||
| 3 | # Type.pm,v 1.6 2004/05/19 06:07:52 sherzodr Exp | ||||||||||||||||||||
| 4 | |||||||||||||||||||||
| 5 | 3 | ▶ | use strict; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 6 | #use diagnostics; | ||||||||||||||||||||
| 7 | 3 | ▶ | use vars ('$VERSION', '@ISA'); | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 8 | 3 | ▶ | use overload ( | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=1.2
| |||||||||||||||||||||
| 9 | '""' => 'id', | ||||||||||||||||||||
| 10 | 0 | ▶ | bool => sub { shift->{id} ? 1 : 0 }, | ||||||||||||||||||
|
Subroutine
__ANON__: not called CC=2 SCAR=17.9
Branch: 1 branch
| |||||||||||||||||||||
| 11 | 3 | fallback => 1 | |||||||||||||||||||
| 12 | 3 | ); | |||||||||||||||||||
| 13 | 3 | ▶ | use Carp; | ||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 14 | |||||||||||||||||||||
| 15 | |||||||||||||||||||||
| 16 | 3 | $VERSION = '1.03'; | |||||||||||||||||||
| 17 | |||||||||||||||||||||
| 18 | |||||||||||||||||||||
| 19 | |||||||||||||||||||||
| 20 | |||||||||||||||||||||
| 21 | |||||||||||||||||||||
| 22 | |||||||||||||||||||||
| 23 | |||||||||||||||||||||
| 24 | |||||||||||||||||||||
| 25 | |||||||||||||||||||||
| 26 | # meant to be overwritten | ||||||||||||||||||||
| 27 | 32 | ▶ | sub _init { | ||||||||||||||||||
|
Subroutine
_init: called CC=1 SCAR=0.0
| |||||||||||||||||||||
| 28 | 32 | my $self = shift; | |||||||||||||||||||
| 29 | |||||||||||||||||||||
| 30 | } | ||||||||||||||||||||
| 31 | |||||||||||||||||||||
| 32 | |||||||||||||||||||||
| 33 | |||||||||||||||||||||
| 34 | |||||||||||||||||||||
| 35 | |||||||||||||||||||||
| 36 | |||||||||||||||||||||
| 37 | |||||||||||||||||||||
| 38 | |||||||||||||||||||||
| 39 | 35 | ▶ | sub new { | ||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.1
Pod
undocumented
| |||||||||||||||||||||
| 40 | 35 | my $class = shift; | |||||||||||||||||||
| 41 | 35 | ▶ | $class = ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 42 | |||||||||||||||||||||
| 43 | 35 | my $self = { @_ }; | |||||||||||||||||||
| 44 | |||||||||||||||||||||
| 45 | 35 | bless $self, $class; | |||||||||||||||||||
| 46 | 35 | $self->_init(); | |||||||||||||||||||
| 47 | 35 | return $self | |||||||||||||||||||
| 48 | } | ||||||||||||||||||||
| 49 | |||||||||||||||||||||
| 50 | |||||||||||||||||||||
| 51 | |||||||||||||||||||||
| 52 | 167 | ▶ | sub id { | ||||||||||||||||||
|
Subroutine
id: called CC=1 SCAR=0.0
Pod
undocumented
| |||||||||||||||||||||
| 53 | 167 | my $self = shift; | |||||||||||||||||||
| 54 | return $self->{id} | ||||||||||||||||||||
| 55 | 167 | } | |||||||||||||||||||
| 56 | |||||||||||||||||||||
| 57 | |||||||||||||||||||||
| 58 | |||||||||||||||||||||
| 59 | |||||||||||||||||||||
| 60 | 79 | ▶ | sub load { | ||||||||||||||||||
|
Subroutine
load: called CC=2 SCAR=7.6
Pod
undocumented
| |||||||||||||||||||||
| 61 | 79 | my $class = shift; | |||||||||||||||||||
| 62 | 79 | ▶ | $class = ref($class) || $class; | ||||||||||||||||||
|
Condition33%1/3
ref $class || $class
MC/DC0%0/2
ref $class || $class
ref $class
$class
Truth table33%1/3
A || B
A= ref $classB= $class
| |||||||||||||||||||||
| 63 | 79 | return bless { id=>$_[0], args=>$_[1] }, $class | |||||||||||||||||||
| 64 | } | ||||||||||||||||||||
| 65 | |||||||||||||||||||||
| 66 | |||||||||||||||||||||
| 67 | |||||||||||||||||||||
| 68 | |||||||||||||||||||||
| 69 | 0 | ▶ | sub dump { | ||||||||||||||||||
|
Subroutine
dump: not called CC=1 SCAR=6.9
Pod
undocumented
| |||||||||||||||||||||
| 70 | 0 | my $self = shift; | |||||||||||||||||||
| 71 | |||||||||||||||||||||
| 72 | 0 | require Data::Dumper; | |||||||||||||||||||
| 73 | 0 | my $d = Data::Dumper->new([$self], [ref $self]); | |||||||||||||||||||
| 74 | 0 | $d->Indent(2); | |||||||||||||||||||
| 75 | 0 | return $d->Dump() | |||||||||||||||||||
| 76 | } | ||||||||||||||||||||
| 77 | |||||||||||||||||||||
| 78 | |||||||||||||||||||||
| 79 | |||||||||||||||||||||
| 80 | |||||||||||||||||||||
| 81 | # member functions for each column type | ||||||||||||||||||||
| 82 | 1 | ▶ | sub substr { | ||||||||||||||||||
|
Subroutine
substr: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 83 | 1 | my $self = shift; | |||||||||||||||||||
| 84 | 1 | ▶ | unless ( @_ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 85 | 0 | croak "$self->substr(): usage error"; | |||||||||||||||||||
| 86 | } | ||||||||||||||||||||
| 87 | 1 | ▶ | return unless defined $self->id(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 88 | 1 | return CORE::substr($self->id, $_[0], $_[1]) | |||||||||||||||||||
| 89 | } | ||||||||||||||||||||
| 90 | |||||||||||||||||||||
| 91 | |||||||||||||||||||||
| 92 | |||||||||||||||||||||
| 93 | 1 | ▶ | sub ucfirst { | ||||||||||||||||||
|
Subroutine
ucfirst: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 94 | 1 | my $self = shift; | |||||||||||||||||||
| 95 | |||||||||||||||||||||
| 96 | 1 | ▶ | if ( @_ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 97 | 0 | croak "$self->ucfirst(): usage error"; | |||||||||||||||||||
| 98 | } | ||||||||||||||||||||
| 99 | 1 | ▶ | return unless defined $self->id(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 100 | 1 | return CORE::ucfirst( $self->id ); | |||||||||||||||||||
| 101 | } | ||||||||||||||||||||
| 102 | |||||||||||||||||||||
| 103 | |||||||||||||||||||||
| 104 | |||||||||||||||||||||
| 105 | 1 | ▶ | sub lcfirst { | ||||||||||||||||||
|
Subroutine
lcfirst: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 106 | 1 | my $self = shift; | |||||||||||||||||||
| 107 | |||||||||||||||||||||
| 108 | 1 | ▶ | if ( @_ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 109 | 0 | croak "$self->lcfirst(): usage error"; | |||||||||||||||||||
| 110 | } | ||||||||||||||||||||
| 111 | 1 | ▶ | return unless defined $self->id(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 112 | 1 | return CORE::lcfirst( $self->id ); | |||||||||||||||||||
| 113 | } | ||||||||||||||||||||
| 114 | |||||||||||||||||||||
| 115 | |||||||||||||||||||||
| 116 | |||||||||||||||||||||
| 117 | 1 | ▶ | sub lc { | ||||||||||||||||||
|
Subroutine
lc: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 118 | 1 | my $self = shift; | |||||||||||||||||||
| 119 | |||||||||||||||||||||
| 120 | 1 | ▶ | if ( @_ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 121 | 0 | croak "$self->lc(): usage error"; | |||||||||||||||||||
| 122 | } | ||||||||||||||||||||
| 123 | 1 | ▶ | return unless defined $self->id(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 124 | 1 | return CORE::lc( $self->id ); | |||||||||||||||||||
| 125 | } | ||||||||||||||||||||
| 126 | |||||||||||||||||||||
| 127 | |||||||||||||||||||||
| 128 | |||||||||||||||||||||
| 129 | 1 | ▶ | sub uc { | ||||||||||||||||||
|
Subroutine
uc: called CC=3 SCAR=12.0
Pod
documented
| |||||||||||||||||||||
| 130 | 1 | my $self = shift; | |||||||||||||||||||
| 131 | |||||||||||||||||||||
| 132 | 1 | ▶ | if ( @_ ) { | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 133 | 0 | croak "$self->uc(): usage error"; | |||||||||||||||||||
| 134 | } | ||||||||||||||||||||
| 135 | 1 | ▶ | return unless defined $self->id(); | ||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||
| 136 | 1 | return CORE::uc( $self->id ); | |||||||||||||||||||
| 137 | } | ||||||||||||||||||||
| 138 | |||||||||||||||||||||
| 139 | |||||||||||||||||||||
| 140 | |||||||||||||||||||||
| 141 | 3 | 1; | |||||||||||||||||||
| 142 | __END__ | ||||||||||||||||||||