Map a raw PHP value to a type

@param string $name
The name of the field. If there is a ':' character, the type is assumed to be that
which follows the ':'
@param mixed $value
The value being checked
323633
public function mapValueToType($name, $value) {
		// just store as an untokenised string
		$type = 'String';
		
		if (strpos($name, ':')) {
			list($name, $type) = explode(':', $name);
			return $type;
		}

		// or an array of strings
		if (is_array($value)) {
			$type = 'MultiValueField';
		}
		
		if (is_double($value)) {
			return 'Double';
		}
		
		if (is_int($value)) {
			return 'Int';
		}

		return $type; 
	}
588859
public function is_type($name, $value, $types){
        if(! $this->not_empty($name, $value)){
            return TRUE;
        }
        $types= explode(',', $types);
        $ok= TRUE;
        if($this->isMultiple($value)){
            foreach ($value['type'] as $type) {
                if (in_array($type, $types)){
                    $ok= FALSE;
                    break;
                }
            }
        }else{
            $ok= in_array($value['type'], $types);
        }        
        
        if($ok){
            return TRUE;
        }else{
            $this->add_message($name, 'is_type', array('types' => $types));
            return FALSE;
        }
    }
913397
public function set_behaviour_var($name, $value) {
        if ($name[0] != '_') {
            throw new coding_exception('Cannot set question type data ' . $name .
                    ' on an attempt step. You can only set variables with names begining with _.');
        }
        return $this->data['-' . $name] = $value;
    }
1330929
public function set(string $name, string $value): void
    {
        $key = strtolower($name);
        $this->headers[$key] = [$name, $value];
    }
1092077
protected function _setField($name, $value)
    {
        // e.g. consumerBillingFirstname
        $this->_consumerData[self::$PREFIX . $name] = (string) $value;
    }
248061
protected function typeByCssSelector($value, $name, $clear = false)
    {
        return $this->typeBySelectorType('cssSelector', $value, $name, $clear);
    }
1064259
public function assign($name, $value = null)
    {
        if (is_string($name)) {
            return $this->data[$name] = $value;
        }

        if (is_array($name)) {
            return $this->assignFromArray($name);
        }

        throw new \InvalidArgumentException("Invalid data type for key, '" .gettype($name) . "' given.");
    }
511080
public static function set($name, $value = null)
	{
		$names = parseCfgName($name);
		if (isset($names[0]))
		{
			$first = array_shift($names);
			$obj = self::getInstance($first);
			if ($obj)
			{
				return $obj->setVal($names, $value);
			}
			else
			{
				return false;
			}
		}
		else
		{
			return false;
		}
	}
691825
public function type($name, $value)
    {
        $schema = Config::table($this->name)->schema();
        if (array_key_exists($name, $schema) && (null === $value || $schema[$name] == gettype($value)))
        {
            return TRUE;
        }

        throw new LazerException('Wrong data type');
    }
1313791
public static function input($type, $name, $value = null, $options = array())
	{
		//if (!isset($options['name'])) $options['name'] = $name;

		// We will get the appropriate value for the given field. We will look for the
		// value in the session for the value in the old input data then we'll look
		// in the model instance if one is set. Otherwise we will just use empty.
		$id = self::getIdAttribute($name, $options);

		// Once we have the type, value, and ID we can merge them into the rest of the
		// attributes array so we can convert them into their HTML attribute format
		// when creating the HTML element. Then, we will return the entire input.
		$merge = compact('type', 'name', 'value', 'id');

		$options = array_merge($options, $merge);

		return '<input' . self::attributes($options) . ' />';
	}
1236813
protected static function formatFieldValue($name, $value) {
		$field	= static::$validator->getField($name);
		if( $field ) {
			$field->getType()->formatValue($field, $value);
		}
		return parent::formatFieldValue($name, $value);
	}
1319847
protected function handleJsonType($name, $value)
    {
        if ($cast = array_get($this->repository->getCasts(), $name)) {
            if (in_array($cast, ['array', 'json'], true)) {
                $value = json_decode($value);
            }
        }

        return $value;
    }
1067668
public function input($type, $name, $value = null, $options = array())
    {
        if ( ! isset($options['name'])) $options['name'] = $name;

        // We will get the appropriate value for the given field. We will look for the
        // value in the session for the value in the old input data then we'll look
        // in the model instance if one is set. Otherwise we will just use empty.
        $id = $this->getIdAttribute($name, $options);

        if ( ! in_array($type, $this->skipValueTypes))
        {
            $value = $this->getValueAttribute($name, $value);
        }

        // Once we have the type, value, and ID we can merge them into the rest of the
        // attributes array so we can convert them into their HTML attribute format
        // when creating the HTML element. Then, we will return the entire input.
        $merge = compact('type', 'value', 'id');

        $options = array_merge($options, $merge);

        return '<input'.$this->html->attributes($options).'>';
    }
1249097
public function set(string $name, $value)
    {
        $this->_data[$name] = $value;

        if(!is_object($value)) {
            $this->_changed[$name] = $value;
        }
    }
32588
public function setRawColumnValue(string $name, $value): void
	{
		$this->columns[$name] = $this->cast($name, $value);
	}
1293408
private function SetInternally($name, $value)
    {
        $schema = $this->GetSchema();
        $mapper = $schema->FieldMapper($name);
        $this->fieldValues[$name] = $mapper->MapValue($value);
    }
176694
protected function setAttribute(string $name, $value) : void
    {
        // Convert values
        switch ($name) {
            case 'name':
                // no break here
            case 'value':
                $value = (string) $value;
                break;
            case 'prefixed':
                $value = (boolean) $value;
                break;
        }

        $this->$name = $value;
    }