Code Duplication    Length = 24-24 lines in 2 locations

controller/RestController.php 2 locations

@@ 638-661 (lines=24) @@
635
     * @param Request $request
636
     * @return object json-ld wrapped broader transitive concept uris and labels.
637
     */
638
    public function broaderTransitive($request)
639
    {
640
        $results = array();
641
        $broaders = $request->getVocab()->getConceptTransitiveBroaders($request->getUri(), $this->parseLimit(), false, $request->getLang());
642
        if (empty($broaders)) {
643
            return $this->returnError('404', 'Not Found', "Could not find concept <{$request->getUri()}>");
644
        }
645
646
        foreach ($broaders as $buri => $vals) {
647
            $result = array('uri' => $buri, 'prefLabel' => $vals['label']);
648
            if (isset($vals['direct'])) {
649
                $result['broader'] = $vals['direct'];
650
            }
651
            $results[$buri] = $result;
652
        }
653
654
        $ret = array_merge_recursive($this->context, array(
655
            '@context' => array('prefLabel' => 'skos:prefLabel', 'broader' => array('@id' => 'skos:broader', '@type' => '@id'), 'broaderTransitive' => array('@id' => 'skos:broaderTransitive', '@container' => '@index'), '@language' => $request->getLang()),
656
            'uri' => $request->getUri(),
657
            'broaderTransitive' => $results)
658
        );
659
660
        return $this->returnJson($ret);
661
    }
662
663
    /**
664
     * Used for querying narrower relations for a concept.
@@ 694-717 (lines=24) @@
691
     * @param Request $request
692
     * @return object json-ld wrapped narrower transitive concept uris and labels.
693
     */
694
    public function narrowerTransitive($request)
695
    {
696
        $results = array();
697
        $narrowers = $request->getVocab()->getConceptTransitiveNarrowers($request->getUri(), $this->parseLimit(), $request->getLang());
698
        if (empty($narrowers)) {
699
            return $this->returnError('404', 'Not Found', "Could not find concept <{$request->getUri()}>");
700
        }
701
702
        foreach ($narrowers as $nuri => $vals) {
703
            $result = array('uri' => $nuri, 'prefLabel' => $vals['label']);
704
            if (isset($vals['direct'])) {
705
                $result['narrower'] = $vals['direct'];
706
            }
707
            $results[$nuri] = $result;
708
        }
709
710
        $ret = array_merge_recursive($this->context, array(
711
            '@context' => array('prefLabel' => 'skos:prefLabel', 'narrower' => array('@id' => 'skos:narrower', '@type' => '@id'), 'narrowerTransitive' => array('@id' => 'skos:narrowerTransitive', '@container' => '@index'), '@language' => $request->getLang()),
712
            'uri' => $request->getUri(),
713
            'narrowerTransitive' => $results)
714
        );
715
716
        return $this->returnJson($ret);
717
    }
718
719
    /**
720
     * Used for querying broader transitive relations