Object/DOM/TextTrackList.pm

filter: Statementstmt 48.0% 24 / 50 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 9 MC/DCmcdc 0.0% 0 / 6 Subroutinesub 42.1% 8 / 19 Podpod 100% 7 / 7 totaltotal 40.2% 39 / 97 CC 8 SCAR 31.5
CC
8
Cov
37%
getTrackById
72.0
addEventListener
2.0
children
2.0
CRAP 23.2
« Object/DOM/Document.pm ↑ Summary Object/XPath.pm »
1 ##----------------------------------------------------------------------------
2 ## HTML Object - ~/lib/HTML/Object/DOM/TextTrackList.pm
3 ## Version v0.2.0
4 ## Copyright(c) 2021 DEGUEST Pte. Ltd.
5 ## Author: Jacques Deguest <jack@deguest.jp>
6 ## Created 2021/12/26
7 ## Modified 2022/09/18
8 ## All rights reserved.
9 ##
10 ##
11 ## This program is free software; you can redistribute it and/or modify it
12 ## under the same terms as Perl itself.
13 ##----------------------------------------------------------------------------
14 package HTML::Object::DOM::TextTrackList;
15 BEGIN
16 1 ▶{
Subroutine BEGIN: called CC=1 SCAR=0.0
17 1 ▶ use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
18 1 ▶ use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
19 1 warnings::register_categories( 'HTML::Object' );
20 1 ▶ use parent qw( HTML::Object::DOM::List );
Subroutine BEGIN: called CC=1 SCAR=0.0
21 1 ▶ use vars qw( $VERSION );
Subroutine BEGIN: called CC=1 SCAR=0.0
22 1 ▶ use Scalar::Util ();
Subroutine BEGIN: called CC=1 SCAR=0.0
23 1 our $VERSION = 'v0.2.0';
24 };
25  
26 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
27 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
28  
29 0 ▶sub addEventListener { return( shift->SUPER::addEventListener({
Subroutine addEventListener: not called CC=1 SCAR=6.9
Pod documented
30 0 addtrack => {
31 add => { property => 'children', type => 'add', event => 'addtrack' },
32 },
33 change => {
34 add => { property => 'selected', type => 'add', event => 'change' },
35 remove => { property => 'selected', type => 'remove', event => 'change' },
36 },
37 removetrack => {
38 remove => { property => 'children', type => 'remove', event => 'removetrack' },
39 },
40 }, @_ ) ); }
41  
42 0 ▶sub children { return( shift->reset(@_)->_set_get_object_array_object({
Subroutine children: not called CC=1 SCAR=6.9
Pod documented
43 field => 'children',
44 callbacks =>
45 {
46 add => '_on_children_add',
47 remove => '_on_children_remove',
48 }
49 }, 'HTML::Object::Element', @_ ) ); }
50  
51 0 ▶sub forEach { return( shift->children->foreach( @_ ) ); }
Subroutine forEach: not called CC=1 SCAR=6.9
Pod documented
52  
53 sub getTrackById
54 0 ▶{
Subroutine getTrackById: not called CC=8 SCAR=42.8
Pod documented
55 0 my $self = shift( @_ );
56 0 my $id = shift( @_ );
57 0 ▶ return if( !defined( $id ) || !CORE::length( "$id" ) );
Branch: 1 branch
BranchTrueFalseTotal
unless defined $id and length "$id" 0 0 0
Condition0%0/3
defined $id and length "$id"
!ll&&!rl&&r
000
MC/DC0%0/2
defined $id and length "$id"
defined $id length "$id"
Truth table0%0/3
A and B
A= defined $idB= length "$id"
ABresult
0X0
100
111
58 0 foreach my $e ( @$self )
59 {
60 0 ▶ if( Scalar::Util::blessed( $e ) &&
Branch: 1 branch
BranchTrueFalseTotal
if (builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")) 0 0 0
Condition0%0/3
builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")
!ll&&!rl&&r
000
MC/DC0%0/2
builtin::blessed($e) and $e->isa("HTML::Object::DOM::Element::Track")
builtin::blessed($e) $e->isa("HTML::Object::DOM::Element::Track")
Truth table0%0/3
A and B
A= builtin::blessed($e)B= $e->isa("HTML::Object::DOM::Element::Track")
ABresult
0X0
100
111
61 $e->isa( 'HTML::Object::DOM::Element::Track' ) )
62 {
63 0 my $e_id = $e->attr( 'id' );
64 0 ▶ return( $e ) if( defined( $e_id ) && $id eq $e_id );
Branch: 1 branch
BranchTrueFalseTotal
if defined $e_id and $id eq $e_id 0 0 0
Condition0%0/3
defined $e_id and $id eq $e_id
!ll&&!rl&&r
000
MC/DC0%0/2
defined $e_id and $id eq $e_id
defined $e_id $id eq $e_id
Truth table0%0/3
A and B
A= defined $e_idB= $id eq $e_id
ABresult
0X0
100
111
65 }
66 }
67 0 return;
68 }
69  
70 # Note: property length is inherited
71  
72 0 ▶sub onaddtrack : lvalue { return( shift->on( 'addtrack', @_ ) ); }
Subroutine onaddtrack: not called CC=1 SCAR=6.9
Pod documented
73  
74 0 ▶sub onchange : lvalue { return( shift->on( 'change', @_ ) ); }
Subroutine onchange: not called CC=1 SCAR=6.9
Pod documented
75  
76 0 ▶sub onremovetrack : lvalue { return( shift->on( 'removetrack', @_ ) ); }
Subroutine onremovetrack: not called CC=1 SCAR=6.9
Pod documented
77  
78 sub _on_children_add
79 0 ▶{
Subroutine _on_children_add: not called CC=1 SCAR=6.9
80 0 my $self = shift( @_ );
81 0 my( $pos, $ref ) = @_;
82 0 my $track = $ref->[0];
83 $self->_trigger_event_for( addtrack => {
84 class => 'HTML::Object::DOM::TrackEvent',
85 callback => sub
86 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
87 0 my $event = shift( @_ );
88 0 $event->track( $track );
89 }
90 0 });
91 }
92  
93 sub _on_children_remove
94 0 ▶{
Subroutine _on_children_remove: not called CC=1 SCAR=6.9
95 0 my $self = shift( @_ );
96 0 my( $pos, $ref ) = @_;
97 0 my $track = $ref->[0];
98 $self->_trigger_event_for( addtrack => {
99 class => 'HTML::Object::DOM::TrackEvent',
100 callback => sub
101 0 ▶ {
Subroutine __ANON__: not called CC=1 SCAR=6.9
102 0 my $event = shift( @_ );
103 0 $event->track( $track );
104 }
105 0 });
106 }
107  
108 1 1;
109 # NOTE: POD
110 __END__
« Object/DOM/Document.pm ↑ Summary Object/XPath.pm »