/** * @param array $data * * @return KeyValuePair * @throws ArgumentException */ public static function initFromArray(array $data) { if (!isset($data['name'])) { throw new ArgumentException('Имя должно быть заполнено.'); } $pair = new KeyValuePair($data['name']); if (isset($data['value'])) { $pair->setValue((string) $data['value']); } if (isset($data['canBeShort'])) { $pair->setCanBeShort((bool) $data['canBeShort']); } return $pair; }
public function testValue() { $pair = new KeyValuePair(''); $pair->setValue('123'); $value = $pair->getValue(); $this->assertEquals('123', $value); }