mirror of
https://github.com/nuxsmin/sysPass.git
synced 2026-03-10 10:26:58 +01:00
* [MOD] Use static types.
* [MOD] CORS headers. * [MOD] Improve Forwarded header lookup. * [ADD] Create interface for configuration data. Signed-off-by: Rubén D <nuxsmin@syspass.org>
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
*
|
||||
* @author nuxsmin
|
||||
* @link https://syspass.org
|
||||
* @copyright 2012-2020, Rubén Domínguez nuxsmin@$syspass.org
|
||||
* @copyright 2012-2021, Rubén Domínguez nuxsmin@$syspass.org
|
||||
*
|
||||
* This file is part of sysPass.
|
||||
*
|
||||
@@ -19,7 +19,7 @@
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
* along with sysPass. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
namespace SP\Mvc\Model;
|
||||
@@ -31,22 +31,16 @@ namespace SP\Mvc\Model;
|
||||
*/
|
||||
final class QueryAssignment
|
||||
{
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $fields = [];
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
protected $values = [];
|
||||
protected array $fields = [];
|
||||
protected array $values = [];
|
||||
|
||||
/**
|
||||
* @param $field
|
||||
* @param $value
|
||||
* @param string $field
|
||||
* @param $value
|
||||
*
|
||||
* @return QueryAssignment
|
||||
* @return $this
|
||||
*/
|
||||
public function addField($field, $value)
|
||||
public function addField(string $field, $value): QueryAssignment
|
||||
{
|
||||
if (strpos($field, '=') === false) {
|
||||
$this->fields[] = $field . ' = ?';
|
||||
@@ -56,43 +50,35 @@ final class QueryAssignment
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param array $fields
|
||||
* @param array $values
|
||||
*
|
||||
* @return QueryAssignment
|
||||
*/
|
||||
public function setFields(array $fields, array $values)
|
||||
public function setFields(array $fields, array $values): QueryAssignment
|
||||
{
|
||||
$this->fields = array_map(function ($value) {
|
||||
return strpos($value, '=') === false ? "$value = ?" : $value;
|
||||
}, $fields);
|
||||
$this->fields = array_map(
|
||||
static function ($value) {
|
||||
return strpos($value, '=') === false
|
||||
? "$value = ?"
|
||||
: $value;
|
||||
},
|
||||
$fields
|
||||
);
|
||||
|
||||
$this->values = array_merge($this->values, $values);
|
||||
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string|null
|
||||
*/
|
||||
public function getAssignments()
|
||||
public function getAssignments(): ?string
|
||||
{
|
||||
return $this->hasFields() ? implode(',', $this->fields) : null;
|
||||
return $this->hasFields()
|
||||
? implode(',', $this->fields)
|
||||
: null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return bool
|
||||
*/
|
||||
public function hasFields()
|
||||
public function hasFields(): bool
|
||||
{
|
||||
return count($this->fields) > 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* @return array
|
||||
*/
|
||||
public function getValues()
|
||||
public function getValues(): array
|
||||
{
|
||||
return $this->values;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user