Code Duplication    Length = 21-21 lines in 2 locations

htdocs/xoops_lib/Xoops/Core/HttpRequest.php 2 locations

@@ 609-629 (lines=21) @@
606
     * @return array associative array of preference (numeric weight >0 <=1.0 )
607
     *               keyed by media types, and sorted by preference
608
     */
609
    public function getAcceptMediaTypes()
610
    {
611
        $types = array();
612
        $accept = $this->getHeader('ACCEPT');
613
614
        if (!empty($accept)) {
615
            $entries = explode(',', $accept);
616
            foreach ($entries as $e) {
617
                $mt = explode(';q=', $e);
618
                if (!isset($mt[1])) {
619
                    $mt[1] = 1.0;
620
                }
621
                $types[trim($mt[0])] = (float) $mt[1];
622
            }
623
624
            // sort list based on value
625
            arsort($types, SORT_NUMERIC);
626
        }
627
628
        return($types);
629
    }
630
631
    /**
632
     * getAcceptedLanguages returns the http-accept-language header as an
@@ 638-658 (lines=21) @@
635
     * @return array associative array of preference (numeric weight >0 <=1.0 )
636
     *               keyed by language code, and sorted by preference
637
     */
638
    public function getAcceptedLanguages()
639
    {
640
        $languages = array();
641
        $accept = $this->getHeader('ACCEPT_LANGUAGE');
642
643
        if (!empty($accept)) {
644
            $entries = explode(',', $accept);
645
            foreach ($entries as $e) {
646
                $l = explode(';q=', $e);
647
                if (!isset($l[1])) {
648
                    $l[1] = 1.0;
649
                }
650
                $languages[trim($l[0])] = (float) $l[1];
651
            }
652
653
            // sort list based on value
654
            arsort($languages, SORT_NUMERIC);
655
        }
656
657
        return($languages);
658
    }
659
}
660