<commit_before><?php
namespace Edu\Cnm\Sprots;

require_once("autoLoader.php");

/**
 * This will be the class for a profile to chose favorite teams
 *
 * @author <NAME> <<EMAIL>>
 **/
class favoriteTeam {
	/**
	*id for the profile that has favorites; this is the foreign key
	*@var int $favoriteTeamProfileId
	**/
	private $favoriteTeamProfileId;
	/**
	*id of the team that is being favorited.
	*@var int $favoriteTeamTeamId
	**/
	private $favoriteTeamTeamId;

	/**
	*constructor for favorting a team
	*
	*@param int|nul
	**/

	/**
	* constructor for forvoritng a team.
	*
	* @param int $newFavoriteTeamProfileId this will be inherieted from the profileId
	* @param int $newFavoriteTeamTeamId this will be inherieted from the teamId
	* @throws \InvalidArgumentException if data types are not valid
  * @throws \RangeException if data values are out of bounds (e.g., strings too long, negative integers)
  * @throws \TypeError if data types violate type hints
  * @throws \Exception if some other exception occurs
	**/

	public function __construct(int $favoriteTeamProfileId, int $favoriteTeamTeamId) {
		try{
			$this->setFavoriteTeamProfileId($newFavoriteTeamProfileId);
			$this->setFavoriteTeamTeamId($newFavoriteTeamTeamId);
		} catch(\InvalidArgumentException $invalidArgument) {
			//rethrow exception to the caller
			throw(new \InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument));
		} catch(\RangeException $rangeException) {
			throw(new \RangeException ($rangeException->getMessage(), 0, $rangeException));
		} catch(\TypeError $typeError) {
			throw(new \TypeError ($typeError->getMessage(), 0, $typeError));
		} catch(\Exception $exception) {
			throw(new \Exception($exception->getMessage(), 0, $exception));
		}
	}

	/**
	 *accessor method for profiles favorite teams.
	 *
	 * @return int|null value of favoriteTeamProfileId
	 **/
	 public function getFavoriteTeamProfileId() {
		 return($this->favoriteTeamProfileId);
	 }

	 /**
		* mutator method for favoriteTeamProfileId
		*
		* @param int|null $newFavoriteTeamProfileId new value of the favoriteTeamProfileId
		* @throws \RangeException if the $newFavoriteTeamProfileIdis not positive
		* @throws \TypeError if $favoriteTeamProfileId is not an integer
		**/
		public function setFavoriteTeamProfileId(int $newFavoriteTeamProfileId) {
			if($newFavoriteTeamProfileId === null) {
				$this->$favoriteTeamProfileId = null;
				return;
			}

			//verify the favoriteTeamProfileId is positive
			if($newFavoriteTeamProfileId <=0) {
				throw(new \RangeException("favoriteTeamProfileId is not a positive number"));
			}

			//verify the favoriteTeamProfileId is an integer.
			//if($newFavoriteTeamProfileId != int)
			//convert and store the favoriteTeamProfileId
			$this->favoriteTeamProfileId = $newFavoriteTeamProfileId;
		}

		/**
		 *accessor method for favoriteTeamTeamId
		 *
		 * @return int|null value of favoriteTeamTeamId
		 **/
		 public function getFavoriteTeamTeamId() {
			 return($this->favoriteTeamTeamId);
		 }

		 /**
			* mutator method for favoriteTeamTeamId
			*
			* @param int|null $newFavoriteTeamTeamId new value of the favoriteTeamProfileId
			* @throws \RangeException if the $newFavoriteTeamTeamId is not positive
			* @throws \TypeError if $favoriteTeamTeamId is not an integer
			**/
			public function setFavoriteTeamTeamId(int $newFavoriteTeamTeamId) {
				if($newFavoriteTeamTeamId === null) {
					$this->$favoriteTeamTeamId = null;
					return;
				}
				//verify the favorite team team id is an integer
				if($newFavoriteTeamTeamId <=0) {
					throw(new \RangeException("favoriteTeamTeamId is not a positive number"));
				}
				//convert and store the favoriteTeamTeamId
				$this->favoriteTeamTeamId = $newFavoriteTeamTeamId;
				}
				/**
				* Inserts this players favoriteTeamProfileId into the favorite table
				*
				* @param \PDO $pdo PDO connection object
				* @throws \PDOException when db related errors occur
				* @throws \TypeError if $pdo is not a PDO connection object
				**/

				public function insert(\PDO $pdo) {
					//enforce the favoriteTeamProfileId isn't already in the db
					if($this->favoriteTeamProfileId !== null) {
						throw(new \PDOException("favoriteTeamProfileId already exists"));
					}

					//create query
					$query = "INSERT INTO favoriteTeam(favoriteTeamProfileId)"
				}
}
<commit_msg>added in insert PDO function, working on delete, and update pdo<commit_after><?php
namespace Edu\Cnm\Sprots;

require_once("autoLoader.php");

/**
 * This will be the class for a profile to chose favorite teams
 *
 * @author <NAME> <<EMAIL>>
 **/
class favoriteTeam {
	/**
	*id for the profile that has favorites; this is the foreign key
	*@var int $favoriteTeamProfileId
	**/
	private $favoriteTeamProfileId;
	/**
	*id of the team that is being favorited.
	*@var int $favoriteTeamTeamId
	**/
	private $favoriteTeamTeamId;

	/**
	*constructor for favorting a team
	*
	*@param int|nul
	**/

	/**
	* constructor for forvoritng a team.
	*
	* @param int $newFavoriteTeamProfileId this will be inherieted from the profileId
	* @param int $newFavoriteTeamTeamId this will be inherieted from the teamId
	* @throws \InvalidArgumentException if data types are not valid
  * @throws \RangeException if data values are out of bounds (e.g., strings too long, negative integers)
  * @throws \TypeError if data types violate type hints
  * @throws \Exception if some other exception occurs
	**/

	public function __construct(int $favoriteTeamProfileId, int $favoriteTeamTeamId) {
		try{
			$this->setFavoriteTeamProfileId($newFavoriteTeamProfileId);
			$this->setFavoriteTeamTeamId($newFavoriteTeamTeamId);
		} catch(\InvalidArgumentException $invalidArgument) {
			//rethrow exception to the caller
			throw(new \InvalidArgumentException($invalidArgument->getMessage(), 0, $invalidArgument));
		} catch(\RangeException $rangeException) {
			throw(new \RangeException ($rangeException->getMessage(), 0, $rangeException));
		} catch(\TypeError $typeError) {
			throw(new \TypeError ($typeError->getMessage(), 0, $typeError));
		} catch(\Exception $exception) {
			throw(new \Exception($exception->getMessage(), 0, $exception));
		}
	}

	/**
	 *accessor method for profiles favorite teams.
	 *
	 * @return int|null value of favoriteTeamProfileId
	 **/
	 public function getFavoriteTeamProfileId() {
		 return($this->favoriteTeamProfileId);
	 }

	 /**
		* mutator method for favoriteTeamProfileId
		*
		* @param int|null $newFavoriteTeamProfileId new value of the favoriteTeamProfileId
		* @throws \RangeException if the $newFavoriteTeamProfileIdis not positive
		* @throws \TypeError if $favoriteTeamProfileId is not an integer
		**/
		public function setFavoriteTeamProfileId(int $newFavoriteTeamProfileId) {
			if($newFavoriteTeamProfileId === null) {
				$this->$favoriteTeamProfileId = null;
				return;
			}

			//verify the favoriteTeamProfileId is positive
			if($newFavoriteTeamProfileId <=0) {
				throw(new \RangeException("favoriteTeamProfileId is not a positive number"));
			}

			//verify the favoriteTeamProfileId is an integer.
			//if($newFavoriteTeamProfileId != int)
			//convert and store the favoriteTeamProfileId
			$this->favoriteTeamProfileId = $newFavoriteTeamProfileId;
		}

		/**
		 *accessor method for favoriteTeamTeamId
		 *
		 * @return int|null value of favoriteTeamTeamId
		 **/
		 public function getFavoriteTeamTeamId() {
			 return($this->favoriteTeamTeamId);
		 }

		 /**
			* mutator method for favoriteTeamTeamId
			*
			* @param int|null $newFavoriteTeamTeamId new value of the favoriteTeamProfileId
			* @throws \RangeException if the $newFavoriteTeamTeamId is not positive
			* @throws \TypeError if $favoriteTeamTeamId is not an integer
			**/
			public function setFavoriteTeamTeamId(int $newFavoriteTeamTeamId) {
				if($newFavoriteTeamTeamId === null) {
					$this->$favoriteTeamTeamId = null;
					return;
				}
				//verify the favorite team team id is an integer
				if($newFavoriteTeamTeamId <=0) {
					throw(new \RangeException("favoriteTeamTeamId is not a positive number"));
				}
				//convert and store the favoriteTeamTeamId
				$this->favoriteTeamTeamId = $newFavoriteTeamTeamId;
				}
				/**
				* Inserts this players favoriteTeamProfileId into the favorite table
				*
				* @param \PDO $pdo PDO connection object
				* @throws \PDOException when db related errors occur
				* @throws \TypeError if $pdo is not a PDO connection object
				**/

				public function insert(\PDO $pdo) {
					//enforce the favoriteTeamProfileId isn't already in the db
					if($this->favoriteTeamProfileId !== null) {
						throw(new \PDOException("favoriteTeamProfileId already exists"));
					}

					//create query
					$query = "INSERT INTO favoriteTeam(favoriteTeamProfileId, favoriteTeamTeamId) VALUES(:favoriteTeamProfileId, :favoriteTeamTeamId)";
					$statement = $pdo->prepare($query);

					//bind the member variables to the place holders in the template
					$parameters = ["favoriteTeamProfileId" => $this->favoriteTeamProfileId, "favoriteTeamTeamId" => $this->$favoriteTeamTeamId]; $statement->excute($parameters);

					//update the null favoriteTeamProfileId with the one that the db gives us
					$this->favoriteTeamProfileId = intval($pdo->lastInsertId());
				}

				/**
				* Deletes this favorite team from associated favoriteTeamProfileId
				*
				* @param \PDO $pdo PDO connection object
				* @throws \PDOException when database related errors occur
				* @throws \Typeerror if $pdo is not a PDO connection object
				**/
				public function delete(\PDO $pdo)	{
					if($this->favoriteTeamProfileId === null && $this->favoriteTeamTeamId === null) {
						throw(new \PDOException("Ids do not exist to delete"));
					}
					// Create query template
					$query = "DELETE FROM favoriteTeam WHERE favoriteTeamProfileId && favoriteTeamTeamId = :favoritePlayerProfileId && :favoriteTeamTeamId";
					$statement = $pdo->execute()
				}
}

{'fraction_non_alphanumeric': 0.10271356783919598, 'fraction_numerical': 0.001206030150753769, 'mean_word_length': 4.046146044624747, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 46, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '513612', 'n_tokens_mistral': 3346, 'n_tokens_neox': 2880, 'n_words': 847}