MultiLanguage/PHP.pm untested

filter: Statementstmt 0.0% 0 / 24 Branchbran 0.0% 0 / 2 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 0.0% 0 / 8 Podpod 0.0% 0 / 5 totaltotal 0.0% 0 / 39 CC 2 SCAR 10.6
CC
2
Cov
0%
match_regex
6.0
wrap
2.0
comment_start
2.0
CRAP 2.9
1 package Regexp::MultiLanguage::PHP;
2
3 use base qw(Regexp::MultiLanguage::BaseDialect);
4 use strict;
5 use warnings;
6
7 =head1 NAME
8
9 Regexp::MultiLanguage::PHP - PHP dialect for Regexp::MultiLanguage.
10
11 =head1 VERSION
12
13 Version 0.03
14
15 =cut
16
17 our $VERSION = 0.03;
18
19 =head1 SYNOPSIS
20
21 This module should not be used directly. Please read the documentation
22 for L<Regexp::MultiLanguage>
23
24 =cut
25
26 sub wrap {
27 my ($this, $code) = @_;
28 return "<?php\n\n" . $code . "\n\n?>";
29 }
30
31 sub match_regex {
32 my ($this, $regex) = @_;
33
34 if ( $regex =~ /^m/ ) {
35 $regex = substr $regex, 1;
36 }
37
38 $regex =~ s/([\\''""])/\\$1/g;
39 return 'preg_match("' . $regex . '", $text)';
40 }
41
42 sub comment_start {
43 return '#';
44 }
45
46 sub make_function {
47 my ($this,$name,$expr) = @_;
48 my $prefix = $this->{'prefix'};
49 return "function $prefix$name( \$text ) { return $expr; }\n";
50 }
51
52 sub function_call {
53 my ($this,$name) = @_;
54 my $prefix = $this->{'prefix'};
55 return "$prefix$name( \$text )";
56 }
57
58 =head1 AUTHOR
59
60 Robby Walker, robwalker@cpan.org
61
62 =head1 COPYRIGHT & LICENSE
63
64 Copyright 2006 Robby Walker, all rights reserved.
65
66 This program is free software; you can redistribute it and/or modify it
67 under the same terms as Perl itself.
68
69 =cut
70
71 1;