Weixin/Client/Remote/_get_qrcode_image.pm

filter: Statementstmt 24.1% 7 / 29 Branchbran 0.0% 0 / 8 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 66.6% 2 / 3 Podpod n/a totaltotal 22.5% 9 / 40 CC 5 SCAR 30.8
CC
5
Cov
19%
_get_qrcode_image
30.0
BEGIN
1.0
BEGIN
1.0
CRAP 21.7
« Weixin/Plugin/PostQRcode.pm ↑ Summary Weixin/Plugin/FuckDaShen.pm »
1 1 ▶use Encode ();
Subroutine BEGIN: called CC=1 SCAR=0.0
2 1 ▶use Encode::Locale;
Subroutine BEGIN: called CC=1 SCAR=0.0
3 0 ▶sub Mojo::Weixin::_get_qrcode_image{
Subroutine _get_qrcode_image: not called CC=5 SCAR=34.0
4 0 my $self = shift;
5 0 my $qrcode_uuid = shift;
6 0 my $api = 'https://login.weixin.qq.com/qrcode/';
7 #my @query_string = (
8 # t => "webwx",
9 #);
10 0 my $url = $api . $qrcode_uuid;
11 0 my $data = $self->http_get($url);
12 0 ▶ if( not defined $data){
Branch: 1 branch
BranchTrueFalseTotal
unless (defined $data) 0 0 0
13 0 $self->error("登录二维码下载失败");
14 0 return 0;
15 }
16 0 $self->clean_qrcode();
17 0 ▶ $self->die("未设置二维码保存路径") if not defined $self->qrcode_path;
Branch: 1 branch
BranchTrueFalseTotal
unless defined $self->qrcode_path 0 0 0
18 0 eval{
19 0 ▶ open(my $fh,">",$self->qrcode_path) or die "$!\n";
Branch: 1 branch
BranchTrueFalseTotal
open my $fh, ">", $self->qrcode_path or die "$!\n" 0 0 0
20 0 binmode $fh;
21 0 print $fh $data;
22 0 close $fh;
23 };
24 0 ▶ if($@){
Branch: 1 branch
BranchTrueFalseTotal
if ($@) 0 0 0
25 0 $self->error("二维码写入文件[ " . $self->qrcode_path . " ]失败: $@");
26 0 return 0;
27 }
28  
29 0 my $filename_for_log = Encode::encode("utf8",Encode::decode(locale_fs,$self->qrcode_path));
30 #$self->info("二维码已下载到本地[ $filename_for_log ]\n二维码原始下载地址[ $url ]");
31 0 $self->info("二维码已下载到本地[ $filename_for_log ]");
32 0 $self->emit(input_qrcode=>$self->qrcode_path,$data);
33 0 return 1;
34 }
35 1 1;
« Weixin/Plugin/PostQRcode.pm ↑ Summary Weixin/Plugin/FuckDaShen.pm »