Passed
Push — master ( a75e06...9022c8 )
by Burak
01:40
created
src/SEOCheckup/Analyze.php 1 patch
Spacing   +70 added lines, -70 removed lines patch added patch discarded remove patch
@@ -47,7 +47,7 @@  discard block
 block discarded – undo
47 47
             'parsed_url'  => $parsed_url,
48 48
             'status'      => $response->getStatusCode(),
49 49
             'headers'     => $response->getHeaders(),
50
-            'page_speed'  => number_format(( microtime(true) - $started_on), 4),
50
+            'page_speed'  => number_format((microtime(true) - $started_on), 4),
51 51
             'dns_records' => is_array($dns_recods) ? $dns_recods : [],
52 52
             'content'     => $response->getBody()->getContents()
53 53
         ];
@@ -118,12 +118,12 @@  discard block
 block discarded – undo
118 118
         {
119 119
             $i++;
120 120
 
121
-            if($i >= 25)
121
+            if ($i >= 25)
122 122
                 break;
123 123
 
124 124
             $status = $this->Request($link)->getStatusCode();
125 125
 
126
-            if(substr($status,0,1) > 3 && $status != 999)
126
+            if (substr($status, 0, 1) > 3 && $status != 999)
127 127
                 $scan['errors']["HTTP {$status}"][] = $link;
128 128
             else
129 129
                 $scan['passed']["HTTP {$status}"][] = $link;
@@ -147,7 +147,7 @@  discard block
 block discarded – undo
147 147
         {
148 148
             foreach ($header as $item)
149 149
             {
150
-                if(strpos(mb_strtolower($item),'cache') !== false)
150
+                if (strpos(mb_strtolower($item), 'cache') !== false)
151 151
                 {
152 152
                     $output['headers'][] = $item;
153 153
                 }
@@ -160,7 +160,7 @@  discard block
 block discarded – undo
160 160
 
161 161
         foreach ($xpath->query('//comment()') as $comment)
162 162
         {
163
-            if(strpos(mb_strtolower($comment->textContent),'cache') !== false)
163
+            if (strpos(mb_strtolower($comment->textContent), 'cache') !== false)
164 164
             {
165 165
                 $output['html'][] = '<!-- '.trim($comment->textContent).' //-->';
166 166
             }
@@ -180,9 +180,9 @@  discard block
 block discarded – undo
180 180
         $output = array();
181 181
         $links  = $this->helpers->GetAttributes($dom, 'link', 'rel');
182 182
 
183
-        foreach($links as $item)
183
+        foreach ($links as $item)
184 184
         {
185
-            if($item == 'canonical')
185
+            if ($item == 'canonical')
186 186
             {
187 187
                 $output[] = $item;
188 188
             }
@@ -203,9 +203,9 @@  discard block
 block discarded – undo
203 203
 
204 204
         foreach ($this->data['headers'] as $key => $header)
205 205
         {
206
-            if($key == 'Content-Type')
206
+            if ($key == 'Content-Type')
207 207
             {
208
-                $output = explode('=', explode(';',$header[0])[1])[1];
208
+                $output = explode('=', explode(';', $header[0])[1])[1];
209 209
             }
210 210
         }
211 211
         return $this->Output($output, __FUNCTION__);
@@ -256,7 +256,7 @@  discard block
 block discarded – undo
256 256
      */
257 257
     public function DeprecatedHTML()
258 258
     {
259
-        $dom       = $this->DOMDocument();
259
+        $dom = $this->DOMDocument();
260 260
         $dom->loadHTML($this->data['content']);
261 261
 
262 262
         $deprecated_tags = array(
@@ -281,9 +281,9 @@  discard block
 block discarded – undo
281 281
 
282 282
         foreach ($deprecated_tags as $tag)
283 283
         {
284
-            $tags   = $dom->getElementsByTagName($tag);
284
+            $tags = $dom->getElementsByTagName($tag);
285 285
 
286
-            if($tags->length > 0)
286
+            if ($tags->length > 0)
287 287
             {
288 288
                 $output[$tag] = $tags->length;
289 289
             }
@@ -299,11 +299,11 @@  discard block
 block discarded – undo
299 299
      */
300 300
     public function DomainLength()
301 301
     {
302
-        $domain = explode('.',$this->data['parsed_url']['host']);
302
+        $domain = explode('.', $this->data['parsed_url']['host']);
303 303
 
304 304
         array_pop($domain);
305 305
 
306
-        $domain = implode('.',$domain);
306
+        $domain = implode('.', $domain);
307 307
 
308 308
         return $this->Output(strlen($domain), __FUNCTION__);
309 309
     }
@@ -318,7 +318,7 @@  discard block
 block discarded – undo
318 318
         $ico    = "{$this->data['parsed_url']['scheme']}://{$this->data['parsed_url']['host']}/favicon.ico";
319 319
         $link   = '';
320 320
 
321
-        if($this->Request($ico)->getStatusCode() === 200)
321
+        if ($this->Request($ico)->getStatusCode() === 200)
322 322
         {
323 323
             $link   = $ico;
324 324
         } else {
@@ -331,7 +331,7 @@  discard block
 block discarded – undo
331 331
 
332 332
             foreach ($tags as $tag)
333 333
             {
334
-                if($tag->getAttribute('rel') == 'shortcut icon' OR $tag->getAttribute('rel') == 'icon')
334
+                if ($tag->getAttribute('rel') == 'shortcut icon' OR $tag->getAttribute('rel') == 'icon')
335 335
                 {
336 336
                     $fav = $tag->getAttribute('href');
337 337
                     break;
@@ -341,10 +341,10 @@  discard block
 block discarded – undo
341 341
             if (!filter_var($fav, FILTER_VALIDATE_URL) === false && $this->Request($fav)->getStatusCode() == 200)
342 342
             {
343 343
                 $link = $fav;
344
-            } else if($this->Request($this->data['parsed_url']['scheme'].'://'.$this->data['parsed_url']['host'].'/'.$fav)->getStatusCode() == 200)
344
+            } else if ($this->Request($this->data['parsed_url']['scheme'].'://'.$this->data['parsed_url']['host'].'/'.$fav)->getStatusCode() == 200)
345 345
             {
346 346
                 $link = $this->data['parsed_url']['scheme'].'://'.$this->data['parsed_url']['host'].'/'.$fav;
347
-            } else if($this->Request($_GET['value'].'/'.$fav)->getStatusCode() == 200)
347
+            } else if ($this->Request($_GET['value'].'/'.$fav)->getStatusCode() == 200)
348 348
             {
349 349
                 $link = $_GET['value'].'/'.$fav;
350 350
             } else {
@@ -373,7 +373,7 @@  discard block
 block discarded – undo
373 373
             $output['frameset'][] = null;
374 374
         }
375 375
 
376
-        $tags   = $dom->getElementsByTagName('frame');
376
+        $tags = $dom->getElementsByTagName('frame');
377 377
         foreach ($tags as $tag)
378 378
         {
379 379
             $output['frame'][] = null;
@@ -400,26 +400,26 @@  discard block
 block discarded – undo
400 400
         $tags   = $dom->getElementsByTagName('script');
401 401
         foreach ($tags as $tag)
402 402
         {
403
-            if($tag->getAttribute('src'))
403
+            if ($tag->getAttribute('src'))
404 404
             {
405 405
                 if (0 === strpos($tag->getAttribute('src'), '//'))
406 406
                 {
407
-                    $href     = $this->data['parsed_url']['scheme'] . ':'.$tag->getAttribute('src');
407
+                    $href     = $this->data['parsed_url']['scheme'].':'.$tag->getAttribute('src');
408 408
                 } else if (0 !== strpos($tag->getAttribute('src'), 'http'))
409 409
                 {
410
-                    $path     = '/' . ltrim($tag->getAttribute('src'), '/');
411
-                    $href     = $this->data['parsed_url']['scheme'] . '://';
410
+                    $path     = '/'.ltrim($tag->getAttribute('src'), '/');
411
+                    $href     = $this->data['parsed_url']['scheme'].'://';
412 412
 
413 413
                     if (isset($this->data['parsed_url']['user']) && isset($this->data['parsed_url']['pass']))
414 414
                     {
415
-                        $href .= $this->data['parsed_url']['user'] . ':' . $this->data['parsed_url']['pass'] . '@';
415
+                        $href .= $this->data['parsed_url']['user'].':'.$this->data['parsed_url']['pass'].'@';
416 416
                     }
417 417
 
418 418
                     $href     .= $this->data['parsed_url']['host'];
419 419
 
420 420
                     if (isset($this->data['parsed_url']['port']))
421 421
                     {
422
-                        $href .= ':' . $this->data['parsed_url']['port'];
422
+                        $href .= ':'.$this->data['parsed_url']['port'];
423 423
                     }
424 424
                     $href    .= $path;
425 425
                 } else {
@@ -432,7 +432,7 @@  discard block
 block discarded – undo
432 432
             }
433 433
         }
434 434
 
435
-        $ua_regex        = "/UA-[0-9]{5,}-[0-9]{1,}/";
435
+        $ua_regex = "/UA-[0-9]{5,}-[0-9]{1,}/";
436 436
 
437 437
         preg_match_all($ua_regex, $script, $ua_id);
438 438
 
@@ -498,14 +498,14 @@  discard block
 block discarded – undo
498 498
      */
499 499
     public function ImageAlt()
500 500
     {
501
-        $dom    = $this->DOMDocument();
501
+        $dom = $this->DOMDocument();
502 502
         $dom->loadHTML($this->data['content']);
503 503
 
504 504
         $tags         = $dom->getElementsByTagName('img');
505 505
         $images       = array();
506 506
         $errors       = array();
507 507
 
508
-        foreach($tags as $item)
508
+        foreach ($tags as $item)
509 509
         {
510 510
             $src      = $item->getAttribute('src');
511 511
             $alt      = $item->getAttribute('alt');
@@ -515,7 +515,7 @@  discard block
 block discarded – undo
515 515
                 'alt' => $alt
516 516
             );
517 517
 
518
-            if($alt == '')
518
+            if ($alt == '')
519 519
             {
520 520
                 $link = $src;
521 521
 
@@ -523,7 +523,7 @@  discard block
 block discarded – undo
523 523
             }
524 524
         }
525 525
 
526
-        $output       = array(
526
+        $output = array(
527 527
             'images'        => $images,
528 528
             'without_alt'   => $errors
529 529
         );
@@ -544,35 +544,35 @@  discard block
 block discarded – undo
544 544
         $tags   = $dom->getElementsByTagName('a');
545 545
         $output = array();
546 546
 
547
-        foreach($tags as $item)
547
+        foreach ($tags as $item)
548 548
         {
549 549
             $link = $item->getAttribute('href');
550 550
 
551
-            if($link != '' && strpos($link,'#') !== 0)
551
+            if ($link != '' && strpos($link, '#') !== 0)
552 552
             {
553 553
                 $link = parse_url($link);
554 554
 
555
-                if(!isset($link['scheme']))
555
+                if (!isset($link['scheme']))
556 556
                 {
557 557
                     $link['scheme'] = $this->data['parsed_url']['scheme'];
558 558
                 }
559 559
 
560
-                if(!isset($link['host']))
560
+                if (!isset($link['host']))
561 561
                 {
562 562
                     $link['host'] = $this->data['parsed_url']['host'];
563 563
                 }
564 564
 
565
-                if(!isset($link['path']))
565
+                if (!isset($link['path']))
566 566
                 {
567 567
                     $link['path'] = '';
568 568
                 } else {
569
-                    if(strpos($link['path'],'/') === false)
569
+                    if (strpos($link['path'], '/') === false)
570 570
                     {
571 571
                         $link['path'] = '/'.$link['path'];
572 572
                     }
573 573
                 }
574 574
 
575
-                if(!isset($link['query']))
575
+                if (!isset($link['query']))
576 576
                 {
577 577
                     $link['query'] = '';
578 578
                 } else {
@@ -607,7 +607,7 @@  discard block
 block discarded – undo
607 607
         $tags   = $dom->getElementsByTagName('style');
608 608
         $output = array();
609 609
 
610
-        foreach($tags as $item)
610
+        foreach ($tags as $item)
611 611
         {
612 612
             $output[] = $this->helpers->Whitespace($item->textContent);
613 613
         }
@@ -629,7 +629,7 @@  discard block
 block discarded – undo
629 629
         foreach ($tags as $tag)
630 630
         {
631 631
             $content = $tag->getAttribute('content');
632
-            if(strtolower($tag->getAttribute('name')) == 'description' && strlen($content) > 0)
632
+            if (strtolower($tag->getAttribute('name')) == 'description' && strlen($content) > 0)
633 633
             {
634 634
                 $output = $content;
635 635
             }
@@ -651,7 +651,7 @@  discard block
 block discarded – undo
651 651
         $output = '';
652 652
         foreach ($tags as $tag)
653 653
         {
654
-            if(isset($tag->nodeValue) && strlen($tag->nodeValue) > 0)
654
+            if (isset($tag->nodeValue) && strlen($tag->nodeValue) > 0)
655 655
             {
656 656
                 $output = $tag->nodeValue;
657 657
             }
@@ -676,13 +676,13 @@  discard block
 block discarded – undo
676 676
         $output = array();
677 677
         foreach ($tags as $tag)
678 678
         {
679
-            if($tag->getAttribute('name') == 'robots')
679
+            if ($tag->getAttribute('name') == 'robots')
680 680
             {
681 681
                 $output[] = $tag->getAttribute('content');
682 682
             }
683 683
         }
684 684
 
685
-        return $this->Output(in_array('nofollow',$output), __FUNCTION__);
685
+        return $this->Output(in_array('nofollow', $output), __FUNCTION__);
686 686
     }
687 687
 
688 688
     /**
@@ -699,13 +699,13 @@  discard block
 block discarded – undo
699 699
         $output = array();
700 700
         foreach ($tags as $tag)
701 701
         {
702
-            if($tag->getAttribute('name') == 'robots')
702
+            if ($tag->getAttribute('name') == 'robots')
703 703
             {
704 704
                 $output[] = $tag->getAttribute('content');
705 705
             }
706 706
         }
707 707
 
708
-        return $this->Output(in_array('noindex',$output), __FUNCTION__);
708
+        return $this->Output(in_array('noindex', $output), __FUNCTION__);
709 709
     }
710 710
 
711 711
     /**
@@ -724,35 +724,35 @@  discard block
 block discarded – undo
724 724
             'img'    => array()
725 725
         );
726 726
 
727
-        $tags   = $dom->getElementsByTagName('link');
727
+        $tags = $dom->getElementsByTagName('link');
728 728
         foreach ($tags as $tag)
729 729
         {
730
-            if($tag->getAttribute('type') == 'text/css' OR $tag->getAttribute('rel') == 'stylesheet')
730
+            if ($tag->getAttribute('type') == 'text/css' OR $tag->getAttribute('rel') == 'stylesheet')
731 731
             {
732 732
                 $output['css'][] = $tag->getAttribute('href');
733 733
             }
734 734
         }
735
-        $output['css']   = array_unique($output['css']);
735
+        $output['css'] = array_unique($output['css']);
736 736
 
737
-        $tags   = $dom->getElementsByTagName('script');
737
+        $tags = $dom->getElementsByTagName('script');
738 738
         foreach ($tags as $tag)
739 739
         {
740
-            if($tag->getAttribute('src') != '')
740
+            if ($tag->getAttribute('src') != '')
741 741
             {
742 742
                 $output['script'][] = $tag->getAttribute('src');
743 743
             }
744 744
         }
745 745
         $output['script'] = array_unique($output['script']);
746 746
 
747
-        $tags   = $dom->getElementsByTagName('img');
747
+        $tags = $dom->getElementsByTagName('img');
748 748
         foreach ($tags as $tag)
749 749
         {
750
-            if($tag->getAttribute('src') != '')
750
+            if ($tag->getAttribute('src') != '')
751 751
             {
752 752
                 $output['img'][] = $tag->getAttribute('src');
753 753
             }
754 754
         }
755
-        $output['img']   = array_unique($output['img']);
755
+        $output['img'] = array_unique($output['img']);
756 756
 
757 757
         return $this->Output($output, __FUNCTION__);
758 758
     }
@@ -780,7 +780,7 @@  discard block
 block discarded – undo
780 780
         $script = $dom->getElementsByTagName('script');
781 781
         $remove = array();
782 782
 
783
-        foreach($script as $item)
783
+        foreach ($script as $item)
784 784
         {
785 785
             $remove[] = $item;
786 786
         }
@@ -792,7 +792,7 @@  discard block
 block discarded – undo
792 792
         $style        = $dom->getElementsByTagName('style');
793 793
         $remove       = array();
794 794
 
795
-        foreach($style as $item)
795
+        foreach ($style as $item)
796 796
         {
797 797
             $remove[] = $item;
798 798
         }
@@ -804,15 +804,15 @@  discard block
 block discarded – undo
804 804
 
805 805
         $page   = $dom->saveHTML();
806 806
         $page   = trim(preg_replace('/<[^>]*>/', ' ', $page));
807
-        $page   = preg_replace('/\s+/', ' ',$page);
808
-        $page   = explode(' ',$page);
807
+        $page   = preg_replace('/\s+/', ' ', $page);
808
+        $page   = explode(' ', $page);
809 809
 
810 810
         $output = array();
811 811
         foreach ($page as $item)
812 812
         {
813 813
             $item = trim($item);
814 814
 
815
-            if($item != '' && strpos($item,'@') !== false)
815
+            if ($item != '' && strpos($item, '@') !== false)
816 816
             {
817 817
                 if (!filter_var($item, FILTER_VALIDATE_EMAIL) === false) {
818 818
                     $output[] = $item;
@@ -834,11 +834,11 @@  discard block
 block discarded – undo
834 834
     {
835 835
         $output               = array();
836 836
 
837
-        $output['actual']     = round(strlen($this->data['content']) / 1024,2);
837
+        $output['actual']     = round(strlen($this->data['content']) / 1024, 2);
838 838
         $output['possible']   = gzcompress($this->data['content'], 9);
839
-        $output['possible']   = round(strlen($output['possible']) / 1024,2);
840
-        $output['percentage'] = round((($output['possible'] * 100) / $output['actual']),2);
841
-        $output['difference'] = round($output['actual'] - $output['possible'],2);
839
+        $output['possible']   = round(strlen($output['possible']) / 1024, 2);
840
+        $output['percentage'] = round((($output['possible'] * 100) / $output['actual']), 2);
841
+        $output['difference'] = round($output['actual'] - $output['possible'], 2);
842 842
 
843 843
         return $this->Output($output, __FUNCTION__);
844 844
     }
@@ -852,7 +852,7 @@  discard block
 block discarded – undo
852 852
     {
853 853
         $output = $this->Request("{$this->data['parsed_url']['scheme']}://{$this->data['parsed_url']['host']}/robots.txt");
854 854
 
855
-        if($output->getStatusCode() === 200)
855
+        if ($output->getStatusCode() === 200)
856 856
         {
857 857
             $output = $output->getBody()->getContents();
858 858
         } else {
@@ -879,7 +879,7 @@  discard block
 block discarded – undo
879 879
         {
880 880
             foreach ($danger as $check)
881 881
             {
882
-                if(strpos(mb_strtolower($key),$check) !== false || strpos(mb_strtolower($header[0]),$check) !== false)
882
+                if (strpos(mb_strtolower($key), $check) !== false || strpos(mb_strtolower($header[0]), $check) !== false)
883 883
                 {
884 884
                     $output[$key] = $header[0];
885 885
                 }
@@ -911,7 +911,7 @@  discard block
 block discarded – undo
911 911
 
912 912
         $tags         = $dom->getElementsByTagName('a');
913 913
         $collect      = array();
914
-        foreach($tags as $item)
914
+        foreach ($tags as $item)
915 915
         {
916 916
             $link = $item->getAttribute('href');
917 917
 
@@ -921,9 +921,9 @@  discard block
 block discarded – undo
921 921
                 {
922 922
                     $host      = parse_url($link)['host'];
923 923
                     $host_name = explode(".", $host);
924
-                    $host_name = $host_name[count($host_name)-2] . "." . $host_name[count($host_name)-1];
924
+                    $host_name = $host_name[count($host_name) - 2].".".$host_name[count($host_name) - 1];
925 925
 
926
-                    if($link != '' && strpos($link,$social) !== false && !in_array($host_name,$collect))
926
+                    if ($link != '' && strpos($link, $social) !== false && !in_array($host_name, $collect))
927 927
                     {
928 928
                         $collect[]      = $host_name;
929 929
                         $output[$key][] = $link;
@@ -945,7 +945,7 @@  discard block
 block discarded – undo
945 945
         $output = array();
946 946
         foreach ($this->data['dns_records'] as $record)
947 947
         {
948
-            if (strtoupper($record['type']) == 'TXT' && strpos($record['txt'],'spf') !== false)
948
+            if (strtoupper($record['type']) == 'TXT' && strpos($record['txt'], 'spf') !== false)
949 949
             {
950 950
                 $output[] = $record['txt'];
951 951
             }
@@ -967,14 +967,14 @@  discard block
 block discarded – undo
967 967
         $dom->loadHTML($this->data['content']);
968 968
 
969 969
         $links  = $this->helpers->GetLinks($dom);
970
-        foreach($links as $link)
970
+        foreach ($links as $link)
971 971
         {
972 972
             $_link = $link;
973 973
             $link  = parse_url($link);
974 974
 
975
-            if(count($link) && (!isset($link['host']) OR $link['host'] == $this->data['parsed_url']['host']))
975
+            if (count($link) && (!isset($link['host']) OR $link['host'] == $this->data['parsed_url']['host']))
976 976
             {
977
-                if(strpos($_link,'_') !== false)
977
+                if (strpos($_link, '_') !== false)
978 978
                 {
979 979
                     $output[] = $_link;
980 980
                 }
Please login to merge, or discard this patch.