blib/lib/Dallycot/AST/Head.pm

filter: Statementstmt 90.0% 27 / 30 Branchbran 50.0% 1 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 88.8% 8 / 9 Podpod 0.0% 0 / 3 totaltotal 81.8% 36 / 44 CC 2 SCAR 2.9
CC
2
Cov
88%
__ANON__
2.1
to_string
2.0
execute
1.0
CRAP 1.3
« blib/lib/Dallycot/AST/Expr.pm ↑ Summary blib/lib/Dallycot/AST/Tail.pm »
1 package Dallycot::AST::Head;
2 29 our $AUTHORITY = 'cpan:JSMITH';
3  
4 # ABSTRACT: Get the first value in a collection or similar value
5  
6 29 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7 29 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 29 ▶use utf8;
Subroutine BEGIN: called CC=1 SCAR=0.0
10 29 ▶use parent 'Dallycot::AST';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 29 ▶use Carp qw(croak);
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14 sub to_string {
15 0 ▶ my ($self) = @_;
Subroutine to_string: not called CC=1 SCAR=6.9
Pod undocumented
16  
17 0 return $self->[0]->to_string . "'";
18 }
19  
20 sub to_rdf {
21 2 ▶ my($self, $model) = @_;
Subroutine to_rdf: called CC=1 SCAR=0.0
Pod undocumented
22  
23 2 my $bnode = $model -> bnode;
24 2 $model -> add_type($bnode, 'loc:Head');
25 2 $model -> add_expression($bnode, $self -> [0]);
26 2 return $bnode;
27 }
28  
29 sub execute {
30 416 ▶ my ( $self, $engine ) = @_;
Subroutine execute: called CC=1 SCAR=0.2
Pod undocumented
31  
32 return $engine->execute( $self->[0] )->then(
33 sub {
34 412 ▶ my ($stream) = @_;
Subroutine __ANON__: called CC=2 SCAR=7.6
35  
36 412 ▶ if ( $stream->can('head') ) {
Branch: 1 branch
BranchTrueFalseTotal
if ($stream->can('head')) { } 412 0 412
37 412 return $stream->head($engine);
38 }
39 else {
40 0 croak "The head operator requires a stream-like object.";
41 }
42 }
43 416 );
44  
45 }
46  
47 29 1;
« blib/lib/Dallycot/AST/Expr.pm ↑ Summary blib/lib/Dallycot/AST/Tail.pm »