/** * Create License object * * @param string $key * * @return License */ public function make($key = '') { // empty license object $license = new License(); // check if id is set if ('' !== $key) { // fetch data from repository $data = $this->repository->retrieve($key); // set data from repository in license object foreach ($data as $dkey => $dval) { $method = 'set_' . $dkey; if (method_exists($license, $method)) { $license->{$method}($dval); } } } // return license return $license; }
/** * Create Activation object * * @param int $id * * @return Activation */ public function make($id = 0) { // empty license object $activation = new Activation(); // check if id is sset if ($id > 0) { // fetch data from repository $data = $this->repository->retrieve($id); // set data from repository in activation object foreach ($data as $dkey => $dval) { $method = 'set_' . $dkey; if (method_exists($activation, $method)) { $activation->{$method}($dval); } } } // return license return $activation; }
/** * Create ApiProduct object * * @param int $id * * @return ApiProduct|bool False if doesn't exist. */ public function make($id = 0) { // empty license object $product = new ApiProduct(); // check if id is sset if ($id > 0) { // fetch data from repository $data = $this->repository->retrieve($id); // If there is no data, the API product may no longer exist. if (empty($data->id)) { return false; } // set data from repository in API product object foreach ($data as $dkey => $dval) { $method = 'set_' . $dkey; if (method_exists($product, $method)) { $product->{$method}($dval); } } } // return product return $product; }