Code Duplication    Length = 16-22 lines in 2 locations

src/Charcoal/Source/ExpressionFieldTrait.php 1 location

@@ 103-124 (lines=22) @@
100
     * @throws InvalidArgumentException If the parameter is not a string.
101
     * @return self
102
     */
103
    public function setTable($table)
104
    {
105
        if ($table === null) {
106
            $this->table = $table;
107
            return $this;
108
        }
109
110
        if (!is_string($table)) {
111
            throw new InvalidArgumentException(
112
                'Table reference must be a string.'
113
            );
114
        }
115
116
        if ($table === '') {
117
            throw new InvalidArgumentException(
118
                'Table reference can not be empty.'
119
            );
120
        }
121
122
        $this->table = $table;
123
        return $this;
124
    }
125
126
    /**
127
     * Determine if a table is assigned.

src/Charcoal/Source/Order.php 1 location

@@ 219-234 (lines=16) @@
216
     * @throws InvalidArgumentException If the direction is not a string.
217
     * @return self
218
     */
219
    public function setDirection($direction)
220
    {
221
        if ($direction === null) {
222
            $this->direction = $direction;
223
            return $this;
224
        }
225
226
        if (!is_string($direction)) {
227
            throw new InvalidArgumentException(
228
                'Direction must be a string.'
229
            );
230
        }
231
232
        $this->direction = strtolower($direction) === 'asc' ? 'ASC' : 'DESC';
233
        return $this;
234
    }
235
236
    /**
237
     * Retrieve the sorting direction.