Skip to content

Commit

Permalink
Merge branch 'type-hinting'
Browse files Browse the repository at this point in the history
  • Loading branch information
VitalyArt committed Jun 2, 2019
2 parents 0fb2868 + 3a69b9a commit fee2c45
Show file tree
Hide file tree
Showing 7 changed files with 154 additions and 141 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
/nbproject
/.idea

composer.lock

/vendor
8 changes: 0 additions & 8 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
language: php
php:
- '5.4'
- '5.5'
- '5.6'
- '7.0'
- '7.1'

script: phpunit
27 changes: 14 additions & 13 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,16 @@
{
"name": "vitalyart/hltv-demo-parser",
"description": "Парсер данных с демки HLTV",
"require": {
"php": ">=5.6"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
},
"autoload": {
"psr-4": {
"VitalyArt\\DemoParser\\": "src/"
}
}
"name": "vitalyart/hltv-demo-parser",
"description": "Парсер данных с демки HLTV",
"require": {
"php": ">=7.1",
"ext-mbstring": "*"
},
"require-dev": {
"phpunit/phpunit": "4.8.*"
},
"autoload": {
"psr-4": {
"VitalyArt\\DemoParser\\": "src/"
}
}
}
28 changes: 19 additions & 9 deletions src/Demo.php
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@

namespace VitalyArt\DemoParser;

use DateTime;

class Demo
{
private $demoProtocol;
Expand All @@ -11,8 +13,16 @@ class Demo
private $entries;
private $startTime;
private $endTime;

public function __construct($demoProtocol, $netProtocol, $mapName, $clientName, $entries, $startTime, $endTime)

public function __construct(
int $demoProtocol,
int $netProtocol,
string $mapName,
string $clientName,
array $entries,
?DateTime $startTime,
?DateTime $endTime
)
{
$this->demoProtocol = $demoProtocol;
$this->netProtocol = $netProtocol;
Expand All @@ -23,37 +33,37 @@ public function __construct($demoProtocol, $netProtocol, $mapName, $clientName,
$this->endTime = $endTime;
}

public function getDemoProtocol()
public function getDemoProtocol(): int
{
return $this->demoProtocol;
}

public function getNetProtocol()
public function getNetProtocol(): int
{
return $this->netProtocol;
}

public function getMapName()
public function getMapName(): string
{
return $this->mapName;
}

public function getClientName()
public function getClientName(): string
{
return $this->clientName;
}

public function getEntries()
public function getEntries(): array
{
return $this->entries;
}

public function getStartTime()
public function getStartTime(): ?DateTime
{
return $this->startTime;
}

public function getEndTime()
public function getEndTime(): ?DateTime
{
return $this->endTime;
}
Expand Down
42 changes: 26 additions & 16 deletions src/Entry.php
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ class Entry
private $frames;
private $offset;
private $fileLength;

/**
* @param string $typeString
* @param integer $type
Expand All @@ -25,7 +25,17 @@ class Entry
* @param integer $offset
* @param integer $fileLength
*/
public function __construct($typeString, $type, $description, $flags, $CDTrack, $trackTime, $frames, $offset, $fileLength)
public function __construct(
string $typeString,
int $type,
string $description,
int $flags,
string $CDTrack,
float $trackTime,
int $frames,
int $offset,
int $fileLength
)
{
$this->typeString = $typeString;
$this->type = $type;
Expand All @@ -42,16 +52,16 @@ public function __construct($typeString, $type, $description, $flags, $CDTrack,
* Entry type
* @return string
*/
public function getTypeString()
public function getTypeString(): string
{
return $this->typeString;
}

/**
* Integer entry type
* @return integer
* @return int
*/
public function getType()
public function getType(): int
{
return $this->type;
}
Expand All @@ -60,16 +70,16 @@ public function getType()
* Description
* @return string
*/
public function getDescription()
public function getDescription(): string
{
return $this->description;
}

/**
* Flags
* @return integer
* @return int
*/
public function getFlags()
public function getFlags(): int
{
return $this->flags;
}
Expand All @@ -78,7 +88,7 @@ public function getFlags()
* CD track
* @return string
*/
public function getCDTrack()
public function getCDTrack(): string
{
return $this->CDTrack;
}
Expand All @@ -87,34 +97,34 @@ public function getCDTrack()
* Track time
* @return float
*/
public function getTrackTime()
public function getTrackTime(): float
{
return $this->trackTime;
}

/**
* Frames
* @return integer
* @return int
*/
public function getFrames()
public function getFrames(): int
{
return $this->frames;
}

/**
* Offset
* @return integer
* @return int
*/
public function getOffset()
public function getOffset(): int
{
return $this->offset;
}

/**
* File length
* @return integer
* @return int
*/
public function getFileLength()
public function getFileLength(): int
{
return $this->fileLength;
}
Expand Down
Loading

0 comments on commit fee2c45

Please sign in to comment.