Skip to content
This repository was archived by the owner on Jul 25, 2022. It is now read-only.

Commit 6aaa45d

Browse files
committed
とりあえず…
1 parent cfea65b commit 6aaa45d

8 files changed

+497
-8
lines changed

composer.json

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,8 @@
55
"require": {
66
"php": ">=7.2",
77
"guzzlehttp/guzzle": "^6.5",
8-
"paquettg/php-html-parser": "^2.1"
8+
"paquettg/php-html-parser": "^2.1",
9+
"analog/analog": "^1.0"
910
},
1011
"license": "GNU General Public License v3.0",
1112
"authors": [

composer.lock

+103-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Challenge.php

+128
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,128 @@
1+
<?php
2+
3+
/**
4+
*
5+
* $$$$$$\ $$\ $$\
6+
* $$ __$$\ $$ | \__|
7+
* $$ / \__|$$ | $$$$$$\ $$$$$$$\ $$$$$$$\ $$\
8+
* $$ | $$ | \____$$\ $$ _____|$$ _____|$$ |
9+
* $$ | $$ | $$$$$$$ |\$$$$$$\ \$$$$$$\ $$ |
10+
* $$ | $$\ $$ |$$ __$$ | \____$$\ \____$$\ $$ |
11+
* \$$$$$$ |$$ |\$$$$$$$ |$$$$$$$ |$$$$$$$ |$$ |
12+
* \______/ \__| \_______|\_______/ \_______/ \__|
13+
*
14+
*
15+
* @author Nerahikada
16+
* @link https://twitter.com/Nerahikada
17+
*
18+
*/
19+
20+
declare(strict_types=1);
21+
22+
namespace Classi;
23+
24+
class Challenge{
25+
26+
/** @var string */
27+
private $url;
28+
29+
/** @var string */
30+
private $title;
31+
32+
/** @var string */
33+
private $name;
34+
35+
/** @var string */
36+
private $teacherName;
37+
38+
/** @var string */
39+
private $teacherMessage;
40+
41+
/** @var \DateTimeImmutable */
42+
private $deliveryDate;
43+
44+
/** @var ?\DateTimeImmutable */
45+
private $deadline = null;
46+
47+
/** @var ?\DateTimeImmutable */
48+
private $lastUpdate = null;
49+
50+
/** @var int */
51+
private $progress;
52+
53+
/** @var string */
54+
private $startUrl;
55+
56+
public function __construct(string $url, string $title, string $name, string $teacherName, string $teacherMessage, $deliveryDate, $deadline = null, $lastUpdate = null, int $progress, string $startUrl){
57+
$this->url = $url;
58+
$this->title = $title;
59+
$this->name = $name;
60+
$this->teacherName = $teacherName;
61+
$this->teacherMessage = $teacherMessage;
62+
$this->deliveryDate = $this->convertDate($deliveryDate);
63+
$this->deadline = $this->convertDate($deadline);
64+
$this->lastUpdate = $this->convertDate($lastUpdate);
65+
if($progress < 0 || $progress > 100){
66+
throw new \RuntimeException('Progress must be in the range 1-100');
67+
}
68+
$this->progress = $progress;
69+
$this->startUrl = $startUrl;
70+
}
71+
72+
private function convertDate($date) : ?\DateTimeImmutable{
73+
if($date instanceof \DateTimeImmutable){
74+
return $date;
75+
}
76+
if($date instanceof \DateTime){
77+
return \DateTimeImmutable::createFromMutable($date);
78+
}
79+
if(empty($date) || $date === '-'){
80+
return null;
81+
}
82+
try{
83+
return new \DateTimeImmutable($date, new \DateTimeZone('Asia/Tokyo'));
84+
}catch(\Exception $e){
85+
throw new \InvalidArgumentException('Invalid value');
86+
}
87+
}
88+
89+
public function getUrl() : string{
90+
return $this->url;
91+
}
92+
93+
public function getTitle() : string{
94+
return $this->title;
95+
}
96+
97+
public function getName() : string{
98+
return $this->name;
99+
}
100+
101+
public function getTeacherName() : string{
102+
return $this->teacherName;
103+
}
104+
105+
public function getTeacherMessage() : string{
106+
return $this->teacherMessage;
107+
}
108+
109+
public function getDeliveryDate() : ?\DateTimeImmutable{
110+
return $this->deliveryDate;
111+
}
112+
113+
public function getDeadline() : ?\DateTimeImmutable{
114+
return $this->deadline;
115+
}
116+
117+
public function getLastUpdate() : ?\DateTimeImmutable{
118+
return $this->lastUpdate;
119+
}
120+
121+
public function getProgress() : int{
122+
return $this->progress;
123+
}
124+
125+
public function getStartUrl() : string{
126+
return $this->startUrl;
127+
}
128+
}

src/ChallengeDelivery.php

+52
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
<?php
2+
3+
/**
4+
*
5+
* $$$$$$\ $$\ $$\
6+
* $$ __$$\ $$ | \__|
7+
* $$ / \__|$$ | $$$$$$\ $$$$$$$\ $$$$$$$\ $$\
8+
* $$ | $$ | \____$$\ $$ _____|$$ _____|$$ |
9+
* $$ | $$ | $$$$$$$ |\$$$$$$\ \$$$$$$\ $$ |
10+
* $$ | $$\ $$ |$$ __$$ | \____$$\ \____$$\ $$ |
11+
* \$$$$$$ |$$ |\$$$$$$$ |$$$$$$$ |$$$$$$$ |$$ |
12+
* \______/ \__| \_______|\_______/ \_______/ \__|
13+
*
14+
*
15+
* @author Nerahikada
16+
* @link https://twitter.com/Nerahikada
17+
*
18+
*/
19+
20+
declare(strict_types=1);
21+
22+
namespace Classi;
23+
24+
class ChallengeDelivery{
25+
26+
/** @var string */
27+
private $url;
28+
29+
/** @var string */
30+
private $name;
31+
32+
/** @var string */
33+
private $subject;
34+
35+
public function __construct(string $url, string $name, string $subject){
36+
$this->url = $url;
37+
$this->name = $name;
38+
$this->subject = $subject;
39+
}
40+
41+
public function getUrl() : string{
42+
return $this->url;
43+
}
44+
45+
public function getName() : string{
46+
return $this->name;
47+
}
48+
49+
public function getSubject() : string{
50+
return $this->subject;
51+
}
52+
}

0 commit comments

Comments
 (0)