Convenience method to set the description $a.

@param mixed $value
@return mixed
8097
protected function set_desca($value) {
        if ($value !== null) {
            if (!is_scalar($value) && !is_array($value) && !($value instanceof stdClass)) {
                throw new coding_exception('$a format not supported.');
            }
            $value = json_encode($value);
        }
        $this->raw_set('desca', $value);
    }
1272434
public function asNtext($value)
    {
        if ($value === null) {
            return $this->getNullDisplay();
        }

        return nl2br(Html::encode($value));
    }
293299
public function set($name, $value = null)
    {
        if (is_string($name)) {
            $name = $this->cleanAttributeName($name);
            if ($value === null && isset($this->props[$name])) {
                unset($this->props[$name]);
            } elseif ($value !== null) {
                $this->props[$name] = $value;
            }
        }

        return $this;
    }
29701
static private function stringify($value)
        {
            if (is_bool($value)) {
                return $value ? '<TRUE>' : '<FALSE>';
            }

            if (is_scalar($value)) {
                $val = (string) $value;

                if (strlen($val) > 100) {
                    $val = substr($val, 0, 97) . '...';
                }

                return $val;
            }

            if (Arrays::is($value)) {
                return '<ARRAY>';
            }

            if (is_object($value)) {
                return get_class($value);
            }

            if (is_resource($value)) {
                return '<RESOURCE>';
            }

            if ($value === null) {
                return '<NULL>';
            }

            return 'unknown';
        }
549137
private function setValue($value)
    {
        switch (gettype($value)) {
            case 'int':
            case 'integer':
                $this->attributes['type'] = 'int';

                return (int) $value;
            case 'real':
            case 'float':
            case 'double':
                $this->attributes['type'] = 'float';

                return (float) $value;
            case 'bool':
            case 'boolean':
                $this->attributes['type'] = 'bool';

                return (bool) $value;
            case 'object':
                if ($value instanceof Collection) {
                    $this->attributes['type'] = 'collection';

                    return json_encode($value);
                }
                $this->attributes['type'] = 'object';

                return json_encode($value);
            case 'array':
                $this->attributes['type'] = 'array';

                return json_encode($value);
            default:
                $this->attributes['type'] = 'string';

                return $value;
        }
    }
1124639
public static function describe($value)
    {
        if (is_scalar($value) || is_null($value)) {
            return var_export($value, true);
        }

        if (is_object($value)) {
            return 'instance of ' . get_class($value);
        }

        return gettype($value);
    }
549842
public function setValue(string $value = null) : Element
    {
        if ($value && !preg_match("@^(https?|ftp)://@", $value)) {
            $value = "http://$value";
        }
        return parent::setValue($value);
    }
291679
public function set($attribute, $value=null) :self {
		// array is passed
		if(is_array($attribute)) {
			// for each associative value in the array
			foreach($attribute as $single_attribute => $single_value) {
				// recurse with a single pair or attribute/value
				$this->set($single_attribute, $single_value);
			}
			// return self
			return($this);
		}
		// specific case of text
		if($attribute == 'text') {
			// use the setter
			$this->setText($value);
		}
		// specific case of html
		elseif($attribute == 'html') {
			// use the setter
			$this->setHtml($value);
		}
		// specific case of style
		elseif($attribute == 'style' && is_array($value)) {
			// use the setter
			$this->setStyle($value);
		}
		// specific case of value
		elseif($attribute == 'value') {
			// use the setter
			$this->setValue($value);
		}
		// any normal attribute
		else {
			// if the value is an array we assemble its content or we set directly
			$this->attributes[$attribute] = is_array($value) ? implode(' ', $value) : $value;
		}
		// return self
		return($this);
	}
523151
public function setValue($value)
    {
        $this->value = $value;
        if (is_string($value) && !empty($value)) {
            $value = Convert::json2array($value);
        } elseif (!is_array($value)) {
            $value = array($value);
        }

        $pattern = "/^{$this->getName()}\[(.*)\]$/";
        foreach ($this->children as $c) {
            $title = $c->getName();
            preg_match($pattern, $title, $matches);
            if (!empty($matches[1]) && isset($value[$matches[1]])) {
                $c->setValue($value[$matches[1]]);
            }
        }

        return $this;
    }
637020
public function setAttr(string $name, string $value)
    {
        $this->attr[$name] = $value;

        return $this;
    }
58951
public function setFrom($value)
    {
        if (is_array($value)) {
            $value = new Person($value);
        }
        return $this->setParameter('from', $value);
    }
825171
public static function describe($value): string
    {
        if (is_array($value)) {
            $value = '<array>';
        } elseif (is_object($value) || is_callable($value) || is_iterable($value)) {
            $value = sprintf('<%s>', get_class($value));
        } else {
            $value = (string)$value;
            if (strlen($value) > 30) {
                $value = substr($value, 0, -3) . '...';
            }
            $value = sprintf('"%s"', $value);
        }
        return $value;
    }
943871
public function describeVar($name, $value)
    {
        return $this->indentation . '/** @var ' . $this->getVarType($value) . ' ' . ($name[0] === '$' ? '' : '$') . $name . " */\n";
    }
381358
public function setAttribute($name, $value){

        $returnValue = false;

        if(is_null($value)){
            return $returnValue;
        }

        if(isset($this->attributes[$name])){

            $datatypeClass = $this->attributes[$name]->getType();
            // check if the attribute needs an element level validation
            if(is_subclass_of($datatypeClass, 'oat\\taoQtiItem\\model\\qti\\datatype\\Identifier')){

                if($value instanceof IdentifiedElement){
                    if($this->validateAttribute($name, $value)){
                        $this->attributes[$name]->setValue($value);
                        $returnValue = true;
                    }else{
                        $vr = print_r($value, true);
                        common_Logger::w($vr);
                        throw new InvalidArgumentException('Invalid identifier attribute value');
                    }
                }elseif(is_string($value)){
                    // try converting to string identifier and search the identified object:
                    $identifier = (string) $value;
                    $elt = $this->getIdentifiedElement($identifier, $datatypeClass::getAllowedClasses());
                    if(!is_null($elt)){
                        // ok, found among allowed classes
                        $this->attributes[$name]->setValue($elt);
                        $returnValue = true;
                    }else{
                        throw new QtiModelException('No QTI element with the identifier has been found: '.$identifier);
                    }
                }
            }else{
                $this->attributes[$name]->setValue($value);
                $returnValue = true;
            }
        }else{
            $this->attributes[$name] = new Generic($value);
            $returnValue = true;
        }

        return $returnValue;
    }
1340091
public function attr($name, $value = null){
        if(is_null($value)){
            return $this->getAttributeValue($name);
        }else{
            return $this->setAttribute($name, $value);
        }
    }
1121922
public function setAttribute($key, $value)
    {
        // First we will check for the presence of a mutator for the set operation
        // which simply lets the developers tweak the attribute as it is set on
        // the model, such as "json_encoding" an listing of data for storage.
        if ($this->hasSetMutator($key)) {
            $method = 'set' . Str::studly($key) . 'Attribute';

            return $this->{$method}($value);
        }

        // If an attribute is listed as a "date", we'll convert it from a DateTime
        // instance into a form proper for storage on the database tables using
        // the connection grammar's date format. We will auto set the values.
        if ($value && $this->isDateAttribute($key)) {
            $value = $this->fromDateTime($value);
        }

        if ($this->isJsonCastable($key) && !is_null($value)) {
            $value = $this->asJson($value);
        }

        // If this attribute contains a JSON ->, we'll set the proper value in the
        // attribute's underlying array. This takes care of properly nesting an
        // attribute in the array's value in the case of deeply nested items.
        if (Str::contains($key, '->')) {
            return $this->fillJsonAttribute($key, $value);
        }

        $this->attributes[$key] = $value;

        return $this;
    }
906164
public function setValue($value)
    {
        if (!isset($value)) {
            unset($this->value);
            return $this;
        }
        $this->value = (string) $value;
        return $this;
    }