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

SendsParameters   A

Complexity

Total Complexity 5

Size/Duplication

Total Lines 29
Duplicated Lines 0 %

Importance

Changes 4
Bugs 0 Features 1
Metric Value
eloc 10
c 4
b 0
f 1
dl 0
loc 29
rs 10
wmc 5

2 Methods

Rating   Name   Duplication   Size   Complexity  
A add() 0 12 4
A addPageToken() 0 3 1
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