예제 #1
0
파일: Link.php 프로젝트: nospor/shorten
 /**
  * Get record for given $link.
  * If not exists create one.
  *
  * @param $link
  * @return array|mixed|null
  */
 public function getOrCreateShort($link)
 {
     $linkRow = $this->get($link);
     if (!$linkRow) {
         //there is no given link, need to create one
         $short = $this->createShort();
         $linkRow = ['link' => $link, 'short' => $short, 'ip' => Helper::getIp()];
         $linkRow = $this->save($linkRow);
     }
     return $linkRow;
 }