Skip to content

Commit 30dd7b6

Browse files
author
Felix
committed
added null to zero handler; updated google lib
1 parent f997f43 commit 30dd7b6

File tree

4 files changed

+35
-8
lines changed

4 files changed

+35
-8
lines changed

CHANGELOG.md

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,17 @@
22

33
All Notable changes to `Laravel AdWords Targeting Idea Service` will be documented in this file.
44

5-
## 1.1.0
6-
- Added Configurable SoapLogger
5+
## [1.2.0] - 2017-07-25
6+
### Added
7+
- Fluent method to convert null values to 0 or empty collection
8+
### Changed
9+
- Using version 28.0.0 of googleads/googleads-php-lib
10+
11+
## [1.1.0] - 2017-06-20
12+
### Added
13+
- Configurable SoapLogger
714
- Console Command For Generating Refresh Token
815
- Auto Discovery For L5.5
916

10-
## 1.0.0
17+
## [1.0.0] - 2017-06-06
1118
- Initial Release

README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ AdWords::location(2276)->language(1001)->searchVolumes(['cheesecake', 'coffee'])
9191
AdWords::withTargetedMonthlySearches()->searchVolumes(['cheesecake', 'coffee']);
9292
```
9393

94+
### Convert NULL values to Zero
95+
```php
96+
AdWords::convertNullToZero()->location(2276)->language(1001)->searchVolumes(['cheesecake', 'coffee']);
97+
```
98+
9499
### Include And Exclude Words For Keyword Ideas
95100
```php
96101
AdWords::location(2642)->exclude(['iphone'])->include(['apple'])->keywordIdeas('iphone');

composer.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"php" : "^7.0",
2424
"illuminate/support": "~5.1",
2525
"illuminate/console": "~5.1",
26-
"googleads/googleads-php-lib": "~27.1.0",
26+
"googleads/googleads-php-lib": "~28.0.0",
2727
"schulzefelix/laravel-data-transfer-object": "^1.0.0"
2828
},
2929
"require-dev": {

src/AdWords.php

Lines changed: 19 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ class AdWords
2222
/** @var bool */
2323
protected $withTargetedMonthlySearches = false;
2424

25+
/** @var bool */
26+
protected $convertNullToZero = false;
27+
2528
/** @var int|null */
2629
protected $language = null;
2730

@@ -72,13 +75,13 @@ public function searchVolumes(array $keywords)
7275
foreach ($missingKeywords as $missingKeyword) {
7376
$missingKeywordInstance = new Keyword([
7477
'keyword' => $missingKeyword,
75-
'search_volume' => null,
76-
'cpc' => null,
77-
'competition' => null,
78+
'search_volume' => $this->convertNullToZero ? 0 : null,
79+
'cpc' => $this->convertNullToZero ? 0 : null,
80+
'competition' => $this->convertNullToZero ? 0 : null,
7881
]);
7982

8083
if ($this->withTargetedMonthlySearches) {
81-
$missingKeywordInstance->targeted_monthly_searches = null;
84+
$missingKeywordInstance->targeted_monthly_searches = $this->convertNullToZero ? collect() : null;
8285
}
8386

8487
$searchVolumes->push($missingKeywordInstance);
@@ -117,6 +120,18 @@ public function withTargetedMonthlySearches()
117120
return $this;
118121
}
119122

123+
/**
124+
* Convert Null Values To Zero.
125+
*
126+
* @return $this
127+
*/
128+
public function convertNullToZero()
129+
{
130+
$this->convertNullToZero = true;
131+
132+
return $this;
133+
}
134+
120135
/**
121136
* Add Language Search Parameter.
122137
*

0 commit comments

Comments
 (0)