Skip to content

Commit

Permalink
Add Author and Book models.
Browse files Browse the repository at this point in the history
Issue MIDU-142
  • Loading branch information
Gavric-Sava committed Mar 11, 2022
1 parent 440488e commit bf7e4d8
Show file tree
Hide file tree
Showing 2 changed files with 105 additions and 0 deletions.
60 changes: 60 additions & 0 deletions src/models/Author.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?php
class Author {
private static $s_id = 0;
private int $id;
private string $firstname;
private string $lastname;
private array $books;

function __construct(string $firstname, string $lastname, array $books) {
$this->firstname = $firstname;
$this->lastname = $lastname;
$this->books = $books;
$this->id = Author::$s_id++;
}

public function getId(): int
{
return $this->id;
}

public function setId(int $id): void
{
$this->id = $id;
}

public function getFirstname(): string
{
return $this->firstname;
}

public function setFirstname(string $firstname): void
{
$this->firstname = $firstname;
}

public function getLastname(): string
{
return $this->lastname;
}

public function setLastname(string $lastname): void
{
$this->lastname = $lastname;
}

public function getBooks(): array
{
return $this->books;
}

public function setBooks(array $books): void
{
$this->books = $books;
}

public function getBookCount(): int {
return count($this->books);
}

}
45 changes: 45 additions & 0 deletions src/models/Book.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
<?php
class Book {
private static $s_id = 0;
private int $id;
private string $name;
private int $year;

function __construct(string $name, int $year) {
$this->name = $name;
$this->year = $year;
$this->id = Book::$s_id++;
}

public function getId(): int
{
return $this->id;
}

public function setId(int $id): void
{
$this->id = $id;
}

public function getName(): string
{
return $this->name;
}

public function setName(string $name): void
{
$this->name = $name;
}

public function getYear(): int
{
return $this->year;
}

public function setYear(int $year): void
{
$this->year = $year;
}

}

0 comments on commit bf7e4d8

Please sign in to comment.