Return a class that has a `slugify()` method, used to convert
strings into slugs.

@param string $attribute

@return \Cocur\Slugify\Slugify
338402
protected function getSlugEngine(string $attribute): Slugify
    {
        static $slugEngines = [];

        $key = get_class($this->model) . '.' . $attribute;

        if (!array_key_exists($key, $slugEngines)) {
            $engine = new Slugify();
            if (method_exists($this->model, 'customizeSlugEngine')) {
                $engine = $this->model->customizeSlugEngine($engine, $attribute);
            }

            $slugEngines[$key] = $engine;
        }

        return $slugEngines[$key];
    }
626812
protected function sluggify($string = '')
    {
        if (!empty($string)) {
            $regexs = ['/[^\w\s_.-]|\s+?/', '/-+?/'];
            $replacer = ['-', ' '];
            $string = Inflector::camelize((preg_replace($regexs, $replacer, strtolower($string))));
        }
        return $string;
    }
133424
public function attr($attribute = null)
    {
        if ($this->isNull($attribute)) {
            return $this->attribute;
        }

        return $this->parent->attr($attribute);
    }
1354502
public function escapeAttribute($attribute)
    {
        $attribute = $this->toUtf8($attribute);

        if ($attribute === '' || ctype_digit($attribute)) {
            return $attribute;
        }

        $result = preg_replace_callback('/[^a-z0-9,\.\-_]/iSu', $this->attributeMatcher, $attribute);
        return $this->fromUtf8($result);
    }
753860
public function addAttribute($attribute) {
      $args = func_get_args();
      $cl = get_class($this);
      if (is_array($attribute))
        $attribute = new BaMLAttribute($attribute[0], $attribute[1]);
      if (is_string($attribute))
        $attribute = new BaMLAttribute($args[0], $args[1]);
      if (!($attribute instanceof BaMLAttribute))
        throw new \CatapultApiException("You can only add type BaMLAttribute or array..");
      if (isset($cl::$params) && !(in_array($attribute->getKey(), $cl::$params)) && sizeof($cl::$params) > 0)
        throw new \CatapultApiException("attribute '" . $attribute->getKey() . "' is not a valid attribute for verb " . $this->getName() . "" . " please use any of the following: " . $this->printAttributes());
      $this->attributes[] = $attribute;
    }
1331712
public static function slugify($text)
    {
        $text = Slugify::create()->slugify($text);

        if (empty($text)) {
            return 'n-a';
        }

        return $text;
    }
909525
public function getLocaled(string $attribute)
    {
        // if always decoded
        if (Any::isArray($this->{$attribute})) {
            return $this->{$attribute}[App::$Request->getLanguage()];
        }

        if (!Any::isStr($attribute) || Str::likeEmpty($this->{$attribute})) {
            return null;
        }

        return Serialize::getDecodeLocale($this->{$attribute});
    }
802661
public function getAttribute($attribute) {
		if (isset($this->_attributes[$attribute])) {
			return $this->_attributes[$attribute];
		}

		return null;
	}
344067
public function group_by( $attribute )
	{
		$new = new self();

		for ( $i = 0; $i < count( $this ); ++$i ) {

			$key = (string)$this[$i]->$attribute; 

			if ( ! isset( $new[$key] ) )
				$new[$key] = new self();

			$new[$key][] = $this[$i];

		}

		return $new;
	}
1371965
public function bySlug($slug, $attributes = ['*'])
    {
        if (!request('preview')) {
            $this->published();
        }
        $model = $this->findBy(column('slug'), $slug, $attributes);

        if (is_null($model)) {
            abort(404);
        }

        return $model;
    }
813901
public function attribute( $attribute, $value )
    {
        if ( null === $value )
        {
            unset( $this->attributes[ $attribute ] );
        } else {
            $this->attributes[ $attribute ] = $value;
        }

        return $this;
    }
688728
public static function slugify($string) {
        $string = strip_tags($string);
        $string = str_replace(['&amp;', '&'], 'and', $string);
        $string = str_replace('@', 'at', $string);

        // @codeCoverageIgnoreStart
        if (class_exists('Titon\G11n\Utility\Inflector')) {
            return \Titon\G11n\Utility\Inflector::slug($string);
        }
        // @codeCoverageIgnoreEnd

        return Inflector::slug($string);
    }
138463
public function removeAttribute(Attribute $attribute)
    {
        foreach ($this->attributes as $key => $attributeElement) {
            if ($attributeElement === $attribute) {
                unset($this->attributes[$key]);
                break;
            }
        }

        return $this;
    }
396816
public function delete($table, $attribute)
    {
        $this->tableName = $table;

        if (is_array($attribute)) {
            return $this->trash($attribute, true);
        } elseif (is_string($attribute) || is_int($attribute)) {
            return $this->trash($attribute);
        }
    }
472930
public static function slugify($string = '')
    {
        $string = preg_replace('~[^\\pL\d]+~u', '-', $string); 
        if (function_exists('iconv')) {
            $string = iconv('utf-8', 'us-ascii//TRANSLIT', $string);
        } 
        $string = preg_replace('~[^-\w]+~', '', strtolower(trim($string, '-')));
        return $string;
    }
771928
protected function generateSlug(string $source, array $config, string $attribute): string
    {
        $separator = $config['separator'];
        $method = $config['method'];
        $maxLength = $config['maxLength'];
        $maxLengthKeepWords = $config['maxLengthKeepWords'];

        if ($method === null) {
            $slugEngine = $this->getSlugEngine($attribute);
            $slug = $slugEngine->slugify($source, $separator);
        } elseif (is_callable($method)) {
            $slug = call_user_func($method, $source, $separator);
        } else {
            throw new \UnexpectedValueException('Sluggable "method" for ' . get_class($this->model) . ':' . $attribute . ' is not callable nor null.');
        }

        $len = mb_strlen($slug);
        if (is_string($slug) && $maxLength && $len > $maxLength) {
            $reverseOffset = $maxLength - $len;
            $lastSeparatorPos = mb_strrpos($slug, $separator, $reverseOffset);
            if ($maxLengthKeepWords && $lastSeparatorPos !== false) {
                $slug = mb_substr($slug, 0, $lastSeparatorPos);
            } else {
                $slug = trim(mb_substr($slug, 0, $maxLength), $separator);
            }
        }

        return $slug;
    }
1017469
public function bySlug($slug, $attributes = ['*'])
    {
        $model = $this
            ->findBy('slug', $slug, $attributes);

        if (is_null($model)) {
            abort(404);
        }

        return $model;
    }