Wikibase/Datatype/Property.pm

filter: Statementstmt 100% 51 / 51 Branchbran 100% 2 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 10 / 10 Podpod 0.0% 0 / 1 totaltotal 98.4% 63 / 64 CC 2 SCAR 1.7
CC
2
Cov
100%
BUILD
2.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.2
« Wikibase/Datatype/Value/Time.pm ↑ Summary Wikibase/Datatype/Value.pm »
1 package Wikibase::Datatype::Property;
2  
3 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 17 ▶use Error::Pure qw(err);
Subroutine BEGIN: called CC=1 SCAR=0.0
7 17 ▶use List::Util 1.33 qw(none);
Subroutine BEGIN: called CC=1 SCAR=0.0
8 17 ▶use Mo qw(build default is);
Subroutine BEGIN: called CC=1 SCAR=0.0
9 17 ▶use Mo::utils qw(check_number check_number_of_items check_required);
Subroutine BEGIN: called CC=1 SCAR=0.0
10 17 ▶use Mo::utils::Array qw(check_array_object);
Subroutine BEGIN: called CC=1 SCAR=0.0
11 17 ▶use Readonly;
Subroutine BEGIN: called CC=1 SCAR=0.0
12  
13 # Pairs data type and datatype.
14 17 Readonly::Hash our %DATA_TYPES => (
15 'commonsMedia' => 'Wikibase::Datatype::Value::String',
16 'external-id' => 'Wikibase::Datatype::Value::String',
17 'geo-shape' => 'Wikibase::Datatype::Value::String',
18 'globe-coordinate' => 'Wikibase::Datatype::Value::Globecoordinate',
19 'math' => 'Wikibase::Datatype::Value::String',
20 'monolingualtext' => 'Wikibase::Datatype::Value::Monolingual',
21 'musical-notation' => 'Wikibase::Datatype::Value::String',
22 'quantity' => 'Wikibase::Datatype::Value::Quantity',
23 'string' => 'Wikibase::Datatype::Value::String',
24 'tabular-data' => 'Wikibase::Datatype::Value::String',
25 'time' => 'Wikibase::Datatype::Value::Time',
26 'url' => 'Wikibase::Datatype::Value::String',
27 'wikibase-item' => 'Wikibase::Datatype::Value::Item',
28 'wikibase-property' => 'Wikibase::Datatype::Value::Property',
29 );
30  
31 17 our $VERSION = 0.40;
32  
33 17 has aliases => (
34 default => [],
35 is => 'ro',
36 );
37  
38 17 has datatype => (
39 is => 'ro',
40 );
41  
42 17 has descriptions => (
43 default => [],
44 is => 'ro',
45 );
46  
47 17 has id => (
48 is => 'ro',
49 );
50  
51 17 has labels => (
52 default => [],
53 is => 'ro',
54 );
55  
56 17 has lastrevid => (
57 is => 'ro',
58 );
59  
60 17 has modified => (
61 is => 'ro',
62 );
63  
64 17 has ns => (
65 default => 120,
66 is => 'ro',
67 );
68  
69 17 has page_id => (
70 is => 'ro',
71 );
72  
73 17 has statements => (
74 default => [],
75 is => 'ro',
76 );
77  
78 17 has title => (
79 is => 'ro',
80 );
81  
82 26 ▶sub BUILD {
Subroutine BUILD: called CC=2 SCAR=6.9
Pod undocumented
83 26 my $self = shift;
84  
85 # Check aliases.
86 26 check_array_object($self, 'aliases', 'Wikibase::Datatype::Value::Monolingual');
87  
88 # Check data type.
89 25 check_required($self, 'datatype');
90 24 ▶ if (none { $self->{'datatype'} eq $_ } keys %DATA_TYPES) {
Subroutine __ANON__: called CC=1 SCAR=0.0
Branch: 1 branch
BranchTrueFalseTotal
if (&none(sub { $self->{"datatype"} eq $_; } , keys %Wikibase::Datatype::Property::DATA_TYPES)) 1 23 24
91 1 err "Parameter 'datatype' = '$self->{'datatype'}' isn't supported.";
92 }
93  
94 # Check descriptions.
95 23 check_array_object($self, 'descriptions', 'Wikibase::Datatype::Value::Monolingual');
96 22 check_number_of_items($self, 'descriptions', 'language', 'Description', 'language');
97  
98 # Check labels.
99 21 check_array_object($self, 'labels', 'Wikibase::Datatype::Value::Monolingual');
100 20 check_number_of_items($self, 'labels', 'language', 'Label', 'language');
101  
102 # Check page id.
103 19 check_number($self, 'page_id');
104  
105 # Check statements.
106 18 check_array_object($self, 'statements', 'Wikibase::Datatype::Statement');
107  
108 17 return;
109 }
110  
111 17 1;
112  
113 __END__
« Wikibase/Datatype/Value/Time.pm ↑ Summary Wikibase/Datatype/Value.pm »