Faker/Plugin/PaymentCardNumber.pm untested

filter: Statementstmt 0.0% 0 / 38 Branchbran 0.0% 0 / 2 Conditioncond 0.0% 0 / 3 MC/DCmcdc n/a Subroutinesub 0.0% 0 / 7 Podpod n/a totaltotal 0.0% 0 / 50 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::PaymentCardNumber;
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 'vendor' => (
27 is => 'ro',
28 isa => 'Str',
29 opt => 1,
30 );
31  
32 # METHODS
33  
34 my $vendor_mapping = {
35 'Visa' => 'visa',
36 'MasterCard' => 'mastercard',
37 'American Express' => 'americanexpress',
38 'Discover Card' => 'discovercard',
39 };
40  
41 method execute() {
42 my $faker = $self->faker;
43 my $vendor = $self->vendor;
44  
45 unless ($vendor && ($vendor = $vendor_mapping->{$vendor})) {
46 $vendor = $faker->random_array_item([values %$vendor_mapping]);
47 }
48  
49 my $options = {
50 all_markers => 1
51 };
52  
53 return $faker->process(["payment", "${vendor}_card"], $options);
54 }
55  
56 1;
57  
58 =encoding utf8
59  
60 =head1 NAME
61  
62 Faker::Plugin::PaymentCardNumber
63  
64 =cut
65  
66 =head1 ABSTRACT
67  
68 Payment Card Number Plugin for Faker
69  
70 =cut
71  
72 =head1 SYNOPSIS
73  
74 package main;
75  
76 use Faker;
77 use Faker::Plugin::PaymentCardNumber;
78  
79 my $f = Faker->new;
80 my $p = Faker::Plugin::PaymentCardNumber->new(faker => $f);
81  
82 my $plugin = $p;
83  
84 =cut
85  
86 =head1 DESCRIPTION
87  
88 This package provides methods for generating fake payment card number data.
89  
90 =cut
91  
92 =head1 INHERITS
93  
94 This package inherits behaviors from:
95  
96 L<Data::Object::Plugin>
97  
98 =cut
99  
100 =head1 LIBRARIES
101  
102 This package uses type constraints from:
103  
104 L<Types::Standard>
105  
106 =cut
107  
108 =head1 ATTRIBUTES
109  
110 This package has the following attributes:
111  
112 =cut
113  
114 =head2 faker
115  
116 faker(ConsumerOf["Faker::Maker"])
117  
118 This attribute is read-only, accepts C<(ConsumerOf["Faker::Maker"])> values, and is required.
119  
120 =cut
121  
122 =head1 METHODS
123  
124 This package implements the following methods:
125  
126 =cut
127  
128 =head2 execute
129  
130 execute() : Str
131  
132 The execute method returns a random fake payment card number.
133  
134 =over 4
135  
136 =item execute example #1
137  
138 # given: synopsis
139  
140 $p->execute;
141  
142 =back
143  
144 =cut
145  
146 =head1 AUTHOR
147  
148 Al Newkirk, C<awncorp@cpan.org>
149  
150 =head1 LICENSE
151  
152 Copyright (C) 2011-2019, Al Newkirk, et al.
153  
154 This is free software; you can redistribute it and/or modify it under the terms
155 of the The Apache License, Version 2.0, as elucidated in the L<"license
156 file"|https://github.com/iamalnewkirk/faker/blob/master/LICENSE>.
157  
158 =head1 ACKNOWLEDGEMENTS
159  
160 Parts of this library were inspired by the following implementations:
161  
162 L<PHP Faker|https://github.com/fzaninotto/Faker>
163  
164 L<Ruby Faker|https://github.com/stympy/faker>
165  
166 L<Python Faker|https://github.com/joke2k/faker>
167  
168 L<JS Faker|https://github.com/Marak/faker.js>
169  
170 L<Elixir Faker|https://github.com/elixirs/faker>
171  
172 =head1 PROJECT
173  
174 L<Wiki|https://github.com/iamalnewkirk/faker/wiki>
175  
176 L<Project|https://github.com/iamalnewkirk/faker>
177  
178 L<Initiatives|https://github.com/iamalnewkirk/faker/projects>
179  
180 L<Milestones|https://github.com/iamalnewkirk/faker/milestones>
181  
182 L<Contributing|https://github.com/iamalnewkirk/faker/blob/master/CONTRIBUTE.md>
183  
184 L<Issues|https://github.com/iamalnewkirk/faker/issues>
185  
186 =cut