Skip to content

Commit 8ae69e1

Browse files
committed
Add Term facade IDG-3105
1 parent 3a5179b commit 8ae69e1

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

src/Facades/Term.php

+26
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
<?php
2+
namespace QuickBooksOnline\API\Facades;
3+
4+
class Term{
5+
6+
public static function create(array $data, $throwException = TRUE){
7+
if(!isset($data) || empty($data)) throw new \Exception("Passed array for creating Term is Empty");
8+
$TermObject = FacadeHelper::reflectArrayToObject("Term", $data, $throwException );
9+
return $TermObject;
10+
}
11+
12+
/**
13+
* This is an immutable function
14+
*/
15+
public static function update($objToUpdate, array $data){
16+
$classOfObj = get_class($objToUpdate);
17+
if(strcmp($classOfObj, FacadeHelper::simpleAppendClassNameSpace("Term")) != 0){
18+
throw new \Exception("Target object class:{" . $classOfObj . "} is not an instance of Term.");
19+
}
20+
$newTermObj = Term::create($data);
21+
$clonedOfObj = FacadeHelper::cloneObj($objToUpdate);
22+
FacadeHelper::mergeObj($clonedOfObj, $newTermObj);
23+
return $clonedOfObj;
24+
}
25+
26+
}

0 commit comments

Comments
 (0)