blib/lib/WWW/Shopify/Liquid/Filter/Sort.pm | |||
---|---|---|---|
Criterion | Covered | Total | % |
statement | 9 | 15 | 60.0 |
branch | 0 | 4 | 0.0 |
condition | n/a | ||
subroutine | 3 | 4 | 75.0 |
pod | 0 | 1 | 0.0 |
total | 12 | 24 | 50.0 |
line | stmt | bran | cond | sub | pod | time | code |
---|---|---|---|---|---|---|---|
1 | #!/usr/bin/perl | ||||||
2 | 21 | 21 | 10374 | use strict; | |||
21 | 44 | ||||||
21 | 704 | ||||||
3 | 21 | 21 | 98 | use warnings; | |||
21 | 31 | ||||||
21 | 657 | ||||||
4 | |||||||
5 | 21 | 21 | 93 | package WWW::Shopify::Liquid::Filter::Sort; use base 'WWW::Shopify::Liquid::Filter'; | |||
21 | 32 | ||||||
21 | 3401 | ||||||
6 | sub operate { | ||||||
7 | 0 | 0 | 0 | my $prop = $_[3]; | |||
8 | 0 | 0 | return [sort(@{$_[2]})] if !$prop; | ||||
0 | |||||||
9 | 0 | 0 | return [sort { $a->$prop <=> $b->$prop } @{$_[2]}] if $prop; | ||||
0 | |||||||
0 | |||||||
10 | } | ||||||
11 | |||||||
12 | 1; |