Skip to content

Commit

Permalink
php documentor
Browse files Browse the repository at this point in the history
  • Loading branch information
mostafa committed Jun 21, 2019
1 parent 2b1accf commit 6563408
Show file tree
Hide file tree
Showing 3 changed files with 108 additions and 15 deletions.
9 changes: 1 addition & 8 deletions src/Facades/Khead.php
Original file line number Diff line number Diff line change
Expand Up @@ -7,15 +7,8 @@
* @author @0devco <with@0dev.co>
* @copyright 0dev.co (https://0dev.co)
*/

use Illuminate\Support\Facades\Facade;

/**
* @author @code4mk <hiremostafa@gmail.com>
* @author @0devco <with@0dev.co>
* @since 2019
* @copyright 0dev.co (https://0dev.co)
*/
use Illuminate\Support\Facades\Facade;

class Khead extends Facade
{
Expand Down
107 changes: 107 additions & 0 deletions src/Head.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,78 +13,185 @@

class Head
{
/**
* hold all metas
*
*@var array $metas
*/
private $metas = [];

/**
* hold all links
*
*@var array $links
*/
private $links = [];

/**
* hold all scripts
*
*@var array $scripts
*/
private $scripts = [];

/**
* hold all open graph meta
*
*@var array $ogs
*/
private $ogs = [];

/**
* hold all twitter cards metas
*
*@var array $cards
*/

private $cards = [];

/**
* hold title
*
*@var string $tilte
*/
private $title;


/**
* set title meta
*
*@param string $data
*@return $this
*/
public function setTitle($data)
{
$this->title = $this->toHtmlString('<title>' . $data . '</title>');
}

/**
* get title meta
*
*@return string
*/
public function getTitle()
{
return $this->title;
}

/**
* set single meta
*
*@param string $name
*@param array $data
*@return $this
*/
public function setMeta($name,$data = [])
{
$this->metas[$name] = $this->toHtmlString('<meta' . $this->attributes($data) . '>');
}

/**
* get single meta
*
*@param string $key
*/
public function getMeta($key)
{
return Arr::get($this->metas, $key, '');
}

/**
* set script
*
*@param string $name
*@param array $data
*@return $this
*/
public function setScript($name,$data = [])
{
$this->scripts[$name] = $this->toHtmlString('<script' . $this->attributes($data) . '>' . "" . "</script>");
}

/**
* get scripts
*
*@param string $key
*/
public function getScript($key)
{
return Arr::get($this->scripts, $key, '');
}

/**
* set link css
*
*@param string $name
*@param array $data
*@return $this
*/
public function setLink($name,$data = [])
{
$this->links[$name] = $this->toHtmlString('<link' . $this->attributes($data) . '>');
}

/**
* get link caa
*
*@param string $key
*/
public function getLink($key)
{
return Arr::get($this->links, $key, '');
}

/**
* set fb open graph meta
*
*@param array $data
*@return $this
*/
public function setOg($data = [])
{
foreach ($data as $key => $value) {
$this->ogs[] = $this->toHtmlString('<meta' . $this->attributes($value) . '>');
}
}

/**
* get fb open graph metas
*
*
*/
public function getOg()
{
$m = "\t\t";
return implode("\n{$m}",$this->ogs);
}

/**
* set twitter cards meta
*
*@param array $data
*@return $this
*/
public function setTwitCards($data = [])
{
foreach ($data as $key => $value) {
$this->cards[] = $this->toHtmlString('<meta' . $this->attributes($value) . '>');
}
}

/**
* get twitter cards
*
*
*/
public function getTwitCards()
{
$m = "\t\t";
return implode("\n{$m}",$this->cards);
}

/**
* Build an HTML attribute string from an array.
*
Expand Down
7 changes: 0 additions & 7 deletions src/LaraHeadServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,13 +12,6 @@
use Illuminate\Foundation\AliasLoader;
use Code4mk\LaraHead\Head as HeadMain;

/**
* @author @code4mk <hiremostafa@gmail.com>
* @author @0devco <with@0dev.co>
* @since 2019
* @copyright 0dev.co (https://0dev.co)
*/

class LaraHeadServiceProvider extends ServiceProvider
{
/**
Expand Down

0 comments on commit 6563408

Please sign in to comment.