File Coverage

blib/lib/Wikibase/Datatype/Value/Property.pm
Criterion Covered Total %
statement 16 16 100.0
branch n/a
condition n/a
subroutine 6 6 100.0
pod 1 2 50.0
total 23 24 95.8


line stmt bran cond sub pod time code
1             package Wikibase::Datatype::Value::Property;
2              
3 5     5   581489 use strict;
  5         62  
  5         146  
4 5     5   40 use warnings;
  5         11  
  5         212  
5              
6 5     5   2311 use Mo qw(build);
  5         2578  
  5         28  
7 5     5   6363 use Wikibase::Datatype::Utils qw(check_property);
  5         19  
  5         115  
8              
9             our $VERSION = 0.30;
10              
11             extends 'Wikibase::Datatype::Value';
12              
13             sub type {
14 1     1 1 13 return 'property';
15             }
16              
17             sub BUILD {
18 4     4 0 27 my $self = shift;
19              
20 4         17 check_property($self, 'value');
21              
22 3         7 return;
23             }
24              
25             1;
26              
27             __END__
28              
29             =pod
30              
31             =encoding utf8
32              
33             =head1 NAME
34              
35             Wikibase::Datatype::Value::Property - Wikibase property value datatype.
36              
37             =head1 SYNOPSIS
38              
39             use Wikibase::Datatype::Value::Property;
40              
41             my $obj = Wikibase::Datatype::Value::Property->new(%params);
42             my $type = $obj->type;
43             my $value = $obj->value;
44              
45             =head1 DESCRIPTION
46              
47             This datatype is property class for representation of wikibase item (e.g. P31).
48              
49             =head1 METHODS
50              
51             =head2 C<new>
52              
53             my $obj = Wikibase::Datatype::Value::Property->new(%params);
54              
55             Constructor.
56              
57             Returns instance of object.
58              
59             =over 8
60              
61             =item * C<value>
62              
63             Value of instance.
64             Parameter must be in form /^P\d+$/ (regexp).
65             Parameter is required.
66              
67             =back
68              
69             =head2 C<type>
70              
71             my $type = $obj->type;
72              
73             Get type. This is constant 'property'.
74              
75             Returns string.
76              
77             =head2 C<value>
78              
79             my $value = $obj->value;
80              
81             Get value.
82              
83             Returns string.
84              
85             =head1 ERRORS
86              
87             new():
88             From Wikibase::Datatype::Value::new():
89             Parameter 'value' is required.
90             From Wikibase::Datatype::Utils::check_property():
91             Parameter 'value' must begin with 'P' and number after it.
92              
93             =head1 EXAMPLE
94              
95             =for comment filename=create_and_print_value_property.pl
96              
97             use strict;
98             use warnings;
99              
100             use Wikibase::Datatype::Value::Property;
101              
102             # Object.
103             my $obj = Wikibase::Datatype::Value::Property->new(
104             'value' => 'P123',
105             );
106              
107             # Get value.
108             my $value = $obj->value;
109              
110             # Get type.
111             my $type = $obj->type;
112              
113             # Print out.
114             print "Type: $type\n";
115             print "Value: $value\n";
116              
117             # Output:
118             # Type: property
119             # Value: P123
120              
121             =head1 DEPENDENCIES
122              
123             L<Error::Pure>,
124             L<Mo>,
125             L<Wikibase::Datatype::Utils>,
126             L<Wikibase::Datatype::Value>.
127              
128             =head1 SEE ALSO
129              
130             =over
131              
132             =item L<Wikibase::Datatype::Value>
133              
134             Wikibase datatypes.
135              
136             =back
137              
138             =head1 REPOSITORY
139              
140             L<https://github.com/michal-josef-spacek/Wikibase-Datatype>
141              
142             =head1 AUTHOR
143              
144             Michal Josef Špaček L<mailto:skim@cpan.org>
145              
146             L<http://skim.cz>
147              
148             =head1 LICENSE AND COPYRIGHT
149              
150             © 2020-2023 Michal Josef Špaček
151              
152             BSD 2-Clause License
153              
154             =head1 VERSION
155              
156             0.30
157              
158             =cut