Passed
Push — master ( 2a03e0...18afc3 )
by Daniel
02:41
created

SendsParameters::addPageToken()   A

Complexity

Conditions 1
Paths 1

Size

Total Lines 3
Code Lines 1

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
cc 1
eloc 1
c 0
b 0
f 0
nc 1
nop 1
dl 0
loc 3
rs 10
1
<?php
2
3
namespace Dacastro4\LaravelGmail\Traits;
4
5
use Illuminate\Support\Arr;
6
7
trait SendsParameters
8
{
9
10
	/**
11
	 * Adds values to the property which is used to send additional parameters in the request.
12
	 *
13
	 * @param $query
14
	 * @param string $column
15
	 * @param bool $encode
16
	 */
17
	public function add( $query, $column = 'q', $encode = true )
18
	{
19
		$query = $encode ? urlencode( $query ) : $query;
20
21
		if ( isset( $this->params[$column] ) ) {
22
			if ( $column === 'pageToken' ) {
23
				$this->params[$column] = $query;
0 ignored issues
show
Bug Best Practice introduced by
The property params does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
24
			} else {
25
				$this->params[$column] = "{$this->params[$column]} $query";
26
			}
27
		} else {
28
			$this->params = Arr::add( $this->params, $column, $query );
29
		}
30
31
	}
32
33
	public function addPageToken( $token )
34
	{
35
		$this->params[ 'pageToken' ] = $token;
0 ignored issues
show
Bug Best Practice introduced by
The property params does not exist. Although not strictly required by PHP, it is generally a best practice to declare properties explicitly.
Loading history...
36
	}
37
}
38