Code Duplication    Length = 13-13 lines in 2 locations

src/relationships/BelongsToRelationship.php 1 location

@@ 41-53 (lines=13) @@
38
        $this->context = $context;
39
    }
40
41
    public function prepareQuery($data) {
42
        // @todo throw an exception when the data doesn't have the local key
43
        $query = $this->getQuery();
44
        if($this->queryPrepared){
45
            $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]);
46
        } else {
47
            $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table'])
48
                ->addFilter($this->options['foreign_key'], $data[$this->options['local_key']])
49
                ->setFirstOnly(true);
50
            $this->queryPrepared = true;
51
        }
52
        return $query;
53
    }
54
55
    public function runSetup() {
56
        $model = $this->container->resolve($this->context->getClassName($this->options['model'], self::BELONGS_TO));

src/relationships/HasManyRelationship.php 1 location

@@ 42-54 (lines=13) @@
39
        $this->context = $context;
40
    }    
41
42
    public function prepareQuery($data)
43
    {
44
        // @todo throw an exception when the data doesn't have the local key
45
        $query = $this->getQuery();
46
        if($this->queryPrepared) {
47
            $query->setBoundData($this->options['foreign_key'], $data[$this->options['local_key']]);
48
        } else {
49
            $query->setTable($this->getModelInstance()->getDBStoreInformation()['quoted_table'])
50
                ->addFilter($this->options['foreign_key'], $data[$this->options['local_key']]);
51
            $this->queryPrepared = true;
52
        }
53
        return $query;
54
    }
55
56
    public function runSetup()
57
    {