Code Duplication    Length = 15-17 lines in 2 locations

src/AbstractActiveRecord.php 2 locations

@@ 109-123 (lines=15) @@
106
	/**
107
	 * {@inheritdoc}
108
	 */
109
	public function update()
110
	{
111
		if (!$this->exists()) {
112
			throw new ActiveRecordException(sprintf('Can not update a non-existent active record entry to the `%s` table.', $this->getActiveRecordTable()));
113
		}
114
115
		try {
116
			$pdoStatement = $this->getPdo()->prepare($this->getUpdateQuery());
117
			$pdoStatement->execute(['id' => $this->getId()] + $this->getActiveRecordAttributes());
118
		} catch (\PDOException $e) {
119
			throw new ActiveRecordException(sprintf('Can not update active record entry %d to the `%s` table.', $this->getId(), $this->getActiveRecordTable()), 0, $e);
120
		}
121
122
		return $this;
123
	}
124
125
	/**
126
	 * Returns the update query.
@@ 144-160 (lines=17) @@
141
	/**
142
	 * {@inheritdoc}
143
	 */
144
	public function delete()
145
	{
146
		if (!$this->exists()) {
147
			throw new ActiveRecordException(sprintf('Can not delete a non-existent active record entry from the `%s` table.', $this->getActiveRecordTable()));
148
		}
149
150
		try {
151
			$pdoStatement = $this->getPdo()->prepare($this->getDeleteQuery());
152
			$pdoStatement->execute(['id' => $this->getId()]);
153
154
			$this->setId(null);
155
		} catch (\PDOException $e) {
156
			throw new ActiveRecordException(sprintf('Can not delete active record entry %d from the `%s` table.', $this->getId(), $this->getActiveRecordTable()), 0, $e);
157
		}
158
159
		return $this;
160
	}
161
162
	/**
163
	 * Returns the delete query.