Faker/Plugin/LoremSentences.pm untested

filter: Statementstmt 0.0% 0 / 32 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 41 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 package Faker::Plugin::LoremSentences;
2  
3 use 5.014;
4  
5 use strict;
6 use warnings;
7  
8 use registry;
9 use routines;
10  
11 use Data::Object::Class;
12 use Data::Object::ClassHas;
13  
14 extends 'Data::Object::Plugin';
15  
16 our $VERSION = '1.03'; # VERSION
17  
18 # ATTRIBUTES
19  
20 has 'faker' => (
21 is => 'ro',
22 isa => 'ConsumerOf["Faker::Maker"]',
23 req => 1,
24 );
25  
26 has 'count' => (
27 is => 'ro',
28 isa => 'Int',
29 def => 3,
30 );
31  
32 has 'words' => (
33 is => 'ro',
34 isa => 'Int',
35 def => 10,
36 );
37  
38 # METHODS
39  
40 method execute() {
41 my $faker = $self->faker;
42 my $words = $self->words;
43 my $count = $self->count;
44  
45 return join ' ', map {
46 $words > 3 ?
47 $faker->lorem_sentence(words => $faker->random_between(3, $words)) :
48 $faker->lorem_sentence
49 } 1..$count;
50 }
51  
52 1;
53  
54 =encoding utf8
55  
56 =head1 NAME
57  
58 Faker::Plugin::LoremSentences
59  
60 =cut
61  
62 =head1 ABSTRACT
63  
64 Lorem Sentences Plugin for Faker
65  
66 =cut
67  
68 =head1 SYNOPSIS
69  
70 package main;
71  
72 use Faker;
73 use Faker::Plugin::LoremSentences;
74  
75 my $f = Faker->new;
76 my $p = Faker::Plugin::LoremSentences->new(faker => $f);
77  
78 my $plugin = $p;
79  
80 =cut
81  
82 =head1 DESCRIPTION
83  
84 This package provides methods for generating fake lorem sentences data.
85  
86 =cut
87  
88 =head1 INHERITS
89  
90 This package inherits behaviors from:
91  
92 L<Data::Object::Plugin>
93  
94 =cut
95  
96 =head1 LIBRARIES
97  
98 This package uses type constraints from:
99  
100 L<Types::Standard>
101  
102 =cut
103  
104 =head1 ATTRIBUTES
105  
106 This package has the following attributes:
107  
108 =cut
109  
110 =head2 faker
111  
112 faker(ConsumerOf["Faker::Maker"])
113  
114 This attribute is read-only, accepts C<(ConsumerOf["Faker::Maker"])> values, and is required.
115  
116 =cut
117  
118 =head1 METHODS
119  
120 This package implements the following methods:
121  
122 =cut
123  
124 =head2 execute
125  
126 execute() : Str
127  
128 The execute method returns a random fake lorem sentences.
129  
130 =over 4
131  
132 =item execute example #1
133  
134 # given: synopsis
135  
136 $p->execute;
137  
138 =back
139  
140 =cut
141  
142 =head1 AUTHOR
143  
144 Al Newkirk, C<awncorp@cpan.org>
145  
146 =head1 LICENSE
147  
148 Copyright (C) 2011-2019, Al Newkirk, et al.
149  
150 This is free software; you can redistribute it and/or modify it under the terms
151 of the The Apache License, Version 2.0, as elucidated in the L<"license
152 file"|https://github.com/iamalnewkirk/faker/blob/master/LICENSE>.
153  
154 =head1 ACKNOWLEDGEMENTS
155  
156 Parts of this library were inspired by the following implementations:
157  
158 L<PHP Faker|https://github.com/fzaninotto/Faker>
159  
160 L<Ruby Faker|https://github.com/stympy/faker>
161  
162 L<Python Faker|https://github.com/joke2k/faker>
163  
164 L<JS Faker|https://github.com/Marak/faker.js>
165  
166 L<Elixir Faker|https://github.com/elixirs/faker>
167  
168 =head1 PROJECT
169  
170 L<Wiki|https://github.com/iamalnewkirk/faker/wiki>
171  
172 L<Project|https://github.com/iamalnewkirk/faker>
173  
174 L<Initiatives|https://github.com/iamalnewkirk/faker/projects>
175  
176 L<Milestones|https://github.com/iamalnewkirk/faker/milestones>
177  
178 L<Contributing|https://github.com/iamalnewkirk/faker/blob/master/CONTRIBUTE.md>
179  
180 L<Issues|https://github.com/iamalnewkirk/faker/issues>
181  
182 =cut