Page Menu
Home
WickedGov Phorge
Search
Configure Global Search
Log In
Files
F1431797
LinesOfCode.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
2 KB
Referenced Files
None
Subscribers
None
LinesOfCode.php
View Options
<?php
declare
(
strict_types
=
1
);
/*
* This file is part of sebastian/lines-of-code.
*
* (c) Sebastian Bergmann <sebastian@phpunit.de>
*
* For the full copyright and license information, please view the LICENSE
* file that was distributed with this source code.
*/
namespace
SebastianBergmann\LinesOfCode
;
/**
* @psalm-immutable
*/
final
class
LinesOfCode
{
/**
* @var int
*/
private
$linesOfCode
;
/**
* @var int
*/
private
$commentLinesOfCode
;
/**
* @var int
*/
private
$nonCommentLinesOfCode
;
/**
* @var int
*/
private
$logicalLinesOfCode
;
/**
* @throws IllogicalValuesException
* @throws NegativeValueException
*/
public
function
__construct
(
int
$linesOfCode
,
int
$commentLinesOfCode
,
int
$nonCommentLinesOfCode
,
int
$logicalLinesOfCode
)
{
if
(
$linesOfCode
<
0
)
{
throw
new
NegativeValueException
(
'$linesOfCode must not be negative'
);
}
if
(
$commentLinesOfCode
<
0
)
{
throw
new
NegativeValueException
(
'$commentLinesOfCode must not be negative'
);
}
if
(
$nonCommentLinesOfCode
<
0
)
{
throw
new
NegativeValueException
(
'$nonCommentLinesOfCode must not be negative'
);
}
if
(
$logicalLinesOfCode
<
0
)
{
throw
new
NegativeValueException
(
'$logicalLinesOfCode must not be negative'
);
}
if
(
$linesOfCode
-
$commentLinesOfCode
!==
$nonCommentLinesOfCode
)
{
throw
new
IllogicalValuesException
(
'$linesOfCode !== $commentLinesOfCode + $nonCommentLinesOfCode'
);
}
$this
->
linesOfCode
=
$linesOfCode
;
$this
->
commentLinesOfCode
=
$commentLinesOfCode
;
$this
->
nonCommentLinesOfCode
=
$nonCommentLinesOfCode
;
$this
->
logicalLinesOfCode
=
$logicalLinesOfCode
;
}
public
function
linesOfCode
():
int
{
return
$this
->
linesOfCode
;
}
public
function
commentLinesOfCode
():
int
{
return
$this
->
commentLinesOfCode
;
}
public
function
nonCommentLinesOfCode
():
int
{
return
$this
->
nonCommentLinesOfCode
;
}
public
function
logicalLinesOfCode
():
int
{
return
$this
->
logicalLinesOfCode
;
}
public
function
plus
(
self
$other
):
self
{
return
new
self
(
$this
->
linesOfCode
()
+
$other
->
linesOfCode
(),
$this
->
commentLinesOfCode
()
+
$other
->
commentLinesOfCode
(),
$this
->
nonCommentLinesOfCode
()
+
$other
->
nonCommentLinesOfCode
(),
$this
->
logicalLinesOfCode
()
+
$other
->
logicalLinesOfCode
(),
);
}
}
File Metadata
Details
Attached
Mime Type
text/x-php
Expires
Sat, May 16, 21:05 (1 d, 13 h)
Storage Engine
local-disk
Storage Format
Raw Data
Storage Handle
0d/e9/09f8b7b05ffa43da0c0b5461edfc
Default Alt Text
LinesOfCode.php (2 KB)
Attached To
Mode
rMWPROD MediaWiki Production
Attached
Detach File
Event Timeline
Log In to Comment