RDF/Trine/Node/Variable.pm

filter: Statementstmt 90.2% 46 / 51 Branchbran 100% 4 / 4 Conditioncond 100% 3 / 3 MC/DCmcdc 100% 2 / 2 Subroutinesub 89.4% 17 / 19 Podpod 100% 8 / 8 totaltotal 91.9% 80 / 87 CC 4 SCAR 4.9
CC
4
Cov
91%
equal
4.0
value
2.0
_compare
2.0
CRAP 1.6
« RDF/Trine/Node/Nil.pm ↑ Summary RDF/Trine/Namespace.pm »
1 # RDF::Trine::Node::Variable
2 # -----------------------------------------------------------------------------
3  
4 =head1 NAME
5  
6 RDF::Trine::Node::Variable - RDF Node class for variables
7  
8 =head1 VERSION
9  
10 This document describes RDF::Trine::Node::Variable version 1.019
11  
12 =cut
13  
14 package RDF::Trine::Node::Variable;
15  
16 68 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
17 68 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 68 ▶no warnings 'redefine';
Subroutine BEGIN: called CC=1 SCAR=0.0
19 68 ▶use base qw(RDF::Trine::Node);
Subroutine BEGIN: called CC=1 SCAR=0.0
20  
21 68 ▶use Data::Dumper;
Subroutine BEGIN: called CC=1 SCAR=0.0
22 68 ▶use Scalar::Util qw(blessed);
Subroutine BEGIN: called CC=1 SCAR=0.0
23 68 ▶use Carp qw(carp croak confess);
Subroutine BEGIN: called CC=1 SCAR=0.0
24  
25 ######################################################################
26  
27 68 our ($VERSION);
28 68 ▶BEGIN {
Subroutine BEGIN: called CC=1 SCAR=0.0
29 68 $VERSION = '1.019';
30 }
31  
32 ######################################################################
33  
34 7 ▶use overload '""' => sub { $_[0]->sse },
Subroutine BEGIN: called CC=1 SCAR=0.0
Subroutine __ANON__: called CC=1 SCAR=0.0
35 68 ;
36  
37 =head1 METHODS
38  
39 Beyond the methods documented below, this class inherits methods from the
40 L<RDF::Trine::Node> class.
41  
42 =over 4
43  
44 =cut
45  
46 =item C<new ( $name )>
47  
48 Returns a new Variable structure.
49  
50 =cut
51  
52 4423 ▶sub new {
Subroutine new: called CC=1 SCAR=0.0
Pod documented
53 4423 my $class = shift;
54 4423 my $name = shift;
55 4423 return bless( [ $name ], $class );
56 }
57  
58 =item C<< name >>
59  
60 Returns the name of the variable.
61  
62 =cut
63  
64 9128 ▶sub name {
Subroutine name: called CC=1 SCAR=0.0
Pod documented
65 9128 my $self = shift;
66 9128 return $self->[0];
67 }
68  
69 =item C<< sse >>
70  
71 Returns the SSE string for this variable.
72  
73 =cut
74  
75 163 ▶sub sse {
Subroutine sse: called CC=1 SCAR=0.0
Pod documented
76 163 my $self = shift;
77 163 my $name = $self->name;
78 163 return qq(?${name});
79 }
80  
81 =item C<< as_string >>
82  
83 Returns a string representation of the node.
84  
85 =cut
86  
87 32 ▶sub as_string {
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
88 32 my $self = shift;
89 32 return '?' . $self->name;
90 }
91  
92 =item C<< value >>
93  
94 Returns the variable name.
95  
96 =cut
97  
98 0 ▶sub value {
Subroutine value: not called CC=1 SCAR=6.9
Pod documented
99 0 my $self = shift;
100 0 return $self->name;
101 }
102  
103 =item C<< as_ntriples >>
104  
105 Returns the node in a string form suitable for NTriples serialization.
106  
107 =cut
108  
109 1 ▶sub as_ntriples {
Subroutine as_ntriples: called CC=1 SCAR=0.0
Pod documented
110 1 my $self = shift;
111 1 throw RDF::Trine::Error::UnimplementedError -text => "Variable nodes aren't allowed in NTriples";
112 }
113  
114 =item C<< type >>
115  
116 Returns the type string of this node.
117  
118 =cut
119  
120 3 ▶sub type {
Subroutine type: called CC=1 SCAR=0.0
Pod documented
121 3 return 'VAR';
122 }
123  
124 =item C<< equal ( $node ) >>
125  
126 Returns true if the two nodes are equal, false otherwise.
127  
128 =cut
129  
130 4 ▶sub equal {
Subroutine equal: called CC=4 SCAR=13.9
Pod documented
131 4 my $self = shift;
132 4 my $node = shift;
133 4 ▶ return 0 unless (blessed($node) and $node->isa('RDF::Trine::Node'));
Branch: 1 branch
BranchTrueFalseTotal
unless builtin::blessed($node) and $node->isa("RDF::Trine::Node") 2 2 4
Condition100%3/3
builtin::blessed($node) and $node->isa("RDF::Trine::Node")
!ll&&!rl&&r
112
MC/DC100%2/2
builtin::blessed($node) and $node->isa("RDF::Trine::Node")
builtin::blessed($node) $node->isa("RDF::Trine::Node")
Truth table100%3/3
A and B
A= builtin::blessed($node)B= $node->isa("RDF::Trine::Node")
ABresult
0X0
100
111
134 2 ▶ return 0 unless ($self->type eq $node->type);
Branch: 1 branch
BranchTrueFalseTotal
unless $self->type eq $node->type 1 1 2
135 1 return ($self->name eq $node->name);
136 }
137  
138 # called to compare two nodes of the same type
139 0 ▶sub _compare {
Subroutine _compare: not called CC=1 SCAR=6.9
140 0 my $a = shift;
141 0 my $b = shift;
142 0 return ($a->name cmp $b->name);
143 }
144  
145 68 1;
146  
147 __END__
« RDF/Trine/Node/Nil.pm ↑ Summary RDF/Trine/Namespace.pm »