Server : Apache System : Linux 145.162.205.92.host.secureserver.net 5.14.0-611.45.1.el9_7.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Apr 1 05:56:53 EDT 2026 x86_64 User : tradze ( 1001) PHP Version : 8.1.34 Disable Function : NONE Directory : /home/tradze/public_html/test.tradze.com/Backup25feb2025/vendor/caffeinated/menus/src/ |
<?php
namespace Caffeinated\Menus;
class Link
{
/**
* @var array
*/
protected $path = array();
/**
* @var string
*/
protected $href;
/**
* @var array
*/
public $attributes = array();
/**
* Constructor.
*
* @param array $path
*/
public function __construct($path = array())
{
$this->path = $path;
}
/**
* Set the link's href property.
*
* @param string $href
* @return \Caffeinated\Menus\Link
*/
public function href($href)
{
$this->href = $href;
return $this;
}
/**
* Make the link active.
*
* @return \Caffeinated\Menus\Link
*/
public function active()
{
$this->attributes['class'] = Builder::formatGroupClass(['class' => 'active'], $this->attributes);
return $this;
}
/**
* Add attributes to the link.
*
* @param mixed
* @return \Caffeinated\Menus\Link|string
*/
public function attr()
{
$args = func_get_args();
if (isset($args[0]) and is_array($args[0])) {
$this->attributes = array_merge($this->attributes, $args[0]);
return $this;
} elseif (isset($args[0]) and isset($args[1])) {
$this->attributes[$args[0]] = $args[1];
return $this;
} elseif (isset($args[0])) {
return isset($this->attributes[$args[0]]) ? $this->attributes[$args[0]] : null;
}
return $this->attributes;
}
/**
* Dynamically retrieve property value.
*
* @param string $property
* @return mixed
*/
public function __get($property)
{
if (property_exists($this, $property)) {
return $this->$property;
}
return $this->attr($property);
}
}