Skip to content

Commit

Permalink
Legoland, wakacje 2024 (#83)
Browse files Browse the repository at this point in the history
  • Loading branch information
krzysztofrewak authored Sep 3, 2024
1 parent 45600c7 commit bf8874b
Show file tree
Hide file tree
Showing 29 changed files with 1,485 additions and 541 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ testing/backend/fixtures/public/*
!testing/backend/fixtures/public/.gitkeep

.env
.php-cs-fixer.cache
1 change: 1 addition & 0 deletions backend/Collections/Breweries.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function addBrewery(Brewery $brewery): static
{
$this->slugService->process($brewery);
$this->breweries->put($brewery->getSlug(), $brewery);

return $this;
}

Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Builders/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ public static function buildFromJson(string $jsonFile): CountriesCollection
$countries = new CountriesCollection();

$data = json_decode($jsonFile, true);

foreach ($data["countries"] as $countryData) {
$countries->addCountry(new Country($countryData["name"], $countryData["original"], $countryData["symbol"], $countryData["tags"]));
}
Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Builders/Trips.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ function (string $jsonFile) use ($trips, $countries, $cities, $tags): void {
$trip = new Trip($data["name"]);

$breweries = new Collection($data["breweries"]);

foreach ($breweries->reverse() as $breweryData) {
$latitude = $breweryData["location"]["coordinates"]["lat"];
$longitude = $breweryData["location"]["coordinates"]["lng"];
Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Cities.php
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public function firstOrCreate(string $name, Country $country): City
$slug = $this->mappings[$name]["slug"] ?? City::slug($name);

$alreadyExisting = $this->cities->get($slug);

if ($alreadyExisting) {
return $alreadyExisting;
}
Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Countries.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public function __construct()
public function addCountry(Country $country): static
{
$this->countries->put($country->getSymbol(), $country);

return $this;
}

Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Notes.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct()
public function addNote(Note $note): static
{
$this->notes->add($note);

return $this;
}

Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Tags.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct()
public function firstOrCreate(string $name): Tag
{
$alreadyExisting = $this->tags->get(Tag::slug($name));

if ($alreadyExisting) {
return $alreadyExisting;
}
Expand Down
1 change: 1 addition & 0 deletions backend/Collections/Trips.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function __construct()
public function addTrip(Trip $trip): static
{
$this->trips->put($trip->getSlug(), $trip);

return $this;
}

Expand Down
3 changes: 3 additions & 0 deletions backend/Models/Calendar/Calendar.php
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ public function addGroup(string $label): Group
{
$group = new Group($label);
$this->groups->add($group);

return $group;
}

Expand All @@ -40,8 +41,10 @@ public function jsonSerialize(): array
protected function findMaxValue(): int
{
$max = 0;

foreach ($this->groups as $group) {
$value = $group->findMaxValue();

if ($value > $max) {
$max = $value;
}
Expand Down
4 changes: 4 additions & 0 deletions backend/Models/Calendar/Group.php
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public function addItem(string $label, string $slug): Item
{
$item = new Item($label, $slug);
$this->items->add($item);

return $item;
}

Expand All @@ -38,8 +39,10 @@ public function getSlug(): string
public function findMaxValue(): int
{
$max = 0;

foreach ($this->items as $item) {
$value = $item->getValue();

if ($value > $max) {
$max = $value;
}
Expand All @@ -56,6 +59,7 @@ public function getExtremes(): ?Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions backend/Models/Calendar/Item.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ public function __construct(
public function addBrewery(Brewery $brewery): static
{
$this->breweries->add($brewery);

return $this;
}

Expand All @@ -51,6 +52,7 @@ public function getExtremes(): ?Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions backend/Models/City.php
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ public static function slug(string $name): string
public function addBrewery(Brewery $brewery): static
{
$this->breweries->add($brewery);

return $this;
}

Expand All @@ -60,6 +61,7 @@ public function getExtremes(): Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions backend/Models/Country.php
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public function __construct(
public function addBrewery(Brewery $brewery): static
{
$this->breweries->add($brewery);

return $this;
}

Expand Down Expand Up @@ -71,6 +72,7 @@ public function getExtremes(): ?Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
4 changes: 4 additions & 0 deletions backend/Models/Statistics.php
Original file line number Diff line number Diff line change
Expand Up @@ -16,24 +16,28 @@ class Statistics implements JsonSerializable
public function setExtremes(array $extremes): static
{
$this->extremes = $extremes;

return $this;
}

public function setWeekdays(array $weekdays): static
{
$this->weekdays = $weekdays;

return $this;
}

public function setMonths(array $months): static
{
$this->months = $months;

return $this;
}

public function setCounter(string $label, int $value): static
{
$this->counters[$label] = $value;

return $this;
}

Expand Down
2 changes: 2 additions & 0 deletions backend/Models/Tag.php
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public static function slug(string $name): string
public function addBrewery(Brewery $brewery): static
{
$this->breweries->add($brewery);

return $this;
}

Expand All @@ -54,6 +55,7 @@ public function getExtremes(): Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
3 changes: 3 additions & 0 deletions backend/Models/Trip.php
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ public function __construct(
public static function buildFromJson(string $jsonFile): static
{
$data = json_decode($jsonFile, true);

return new static($data["name"]);
}

Expand All @@ -45,6 +46,7 @@ public function addBrewery(Brewery $brewery): static
{
$this->breweries->put($brewery->getSlug(), $brewery);
$this->countries->prepend($brewery->getCountry(), $brewery->getCountry()->getSlug());

return $this;
}

Expand Down Expand Up @@ -84,6 +86,7 @@ public function getExtremes(): ?Extremes
public function setExtremes(Extremes $extremes): static
{
$this->extremes = $extremes;

return $this;
}

Expand Down
1 change: 1 addition & 0 deletions backend/Services/BreweryIndexer.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ class BreweryIndexer
public static function index(Breweries $breweries): void
{
$i = 1;

foreach ($breweries->getAll()->reverse() as $brewery) {
$brewery->setId($i++);
}
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
"vlucas/phpdotenv": "^5.3.0"
},
"require-dev": {
"blumilksoftware/codestyle": "^1.3.0",
"blumilksoftware/codestyle": "^3.3",
"phpunit/phpunit": "^9"
},
"scripts": {
Expand Down
Loading

0 comments on commit bf8874b

Please sign in to comment.