Skip to content

Commit 179e854

Browse files
committed
Initial commit
0 parents  commit 179e854

File tree

6 files changed

+130
-0
lines changed

6 files changed

+130
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
build
2+
vendor
3+
composer.lock

.phpunit.result.cache

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
C:37:"PHPUnit\Runner\DefaultTestResultCache":420:{a:2:{s:7:"defects";a:2:{s:76:"CodingWisely\ChuckNorisJokes\Tests\JokeFactoryTest::it_returns_a_random_joke";i:4;s:84:"CodingWisely\Thoughts\Tests\ProgrammingThoughtsFactoryTest::it_returns_a_random_joke";i:3;}s:5:"times";a:2:{s:76:"CodingWisely\ChuckNorisJokes\Tests\JokeFactoryTest::it_returns_a_random_joke";d:0.007;s:84:"CodingWisely\Thoughts\Tests\ProgrammingThoughtsFactoryTest::it_returns_a_random_joke";d:0.007;}}}

composer.json

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
{
2+
"name": "coding-wisely/thoughts",
3+
"description": "Random thoughts",
4+
"type": "library",
5+
"license": "MIT",
6+
"authors": [
7+
{
8+
"name": "Vladimir Nikolic",
9+
"email": "[email protected]"
10+
}
11+
],
12+
"minimum-stability": "stable",
13+
"require": {},
14+
"autoload": {
15+
"psr-4": {
16+
"CodingWisely\\Thoughts\\": "src/"
17+
}
18+
},
19+
"autoload-dev": {
20+
"psr-4": {
21+
"CodingWisely\\Thoughts\\Tests\\": "tests/"
22+
}
23+
},
24+
"require-dev": {
25+
"phpunit/phpunit": "^8.5"
26+
}
27+
}

phpunit.xml.dist

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<phpunit
3+
bootstrap="vendor/autoload.php"
4+
backupGlobals="false"
5+
backupStaticAttributes="false"
6+
colors="true"
7+
verbose="true"
8+
convertErrorsToExceptions="true"
9+
convertNoticesToExceptions="true"
10+
convertWarningsToExceptions="true"
11+
processIsolation="false"
12+
stopOnFailure="false"
13+
>
14+
<testsuites>
15+
<testsuite name="Coding Wisely Thoughts Test Suite">
16+
<directory>
17+
tests
18+
</directory>
19+
</testsuite>
20+
</testsuites>
21+
<filter>
22+
<whitelist>
23+
<directory suffix=".php">src/</directory>
24+
</whitelist>
25+
</filter>
26+
<logging>
27+
<log type="tap" target="build/report.tap" />
28+
<log type="junit" target="build/report.junit.xml" />
29+
<log type="coverage-text" target="build/coverage.txt" />
30+
<log type="coverage-clover" target="build/logs/clover.xml" />
31+
</logging>
32+
</phpunit>

src/ProgrammingThoughtsFactory.php

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
<?php
2+
3+
namespace CodingWisely\Thoughts;
4+
5+
class ProgrammingThoughtsFactory
6+
{
7+
protected $thoughts = [
8+
"Talk is cheap. Show me the code. ― Linus Torvalds",
9+
"Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live - John Woods",
10+
"Any fool can write code that a computer can understand. Good programmers write code that humans can understand. - Martin Flower",
11+
"Truth can only be found in one place: the code. - Robert C. Martin, Clean Code",
12+
"That's the thing about people who think they hate computers. What they really hate is lousy programmers. - Larry Niven",
13+
"You've baked a really lovely cake, but then you've used dog shit for frosting. - Steve Jobs",
14+
"The most important property of a program is whether it accomplishes the intention of its user. - C.A.R. Hoare",
15+
"Everyday life is like programming, I guess. If you love something you can put beauty into it. - Donald Knuth",
16+
"I'm a programmer. I like programming. And the best way I've found to have a positive impact on code is to write it. Robert C.Martin, Clean Architecture",
17+
"Abstraction is the elimination of the irrelevant and the amplification of the essential. - Robert C. Martin, Agile Principles, Patterns, and Practices in C#",
18+
"It is what it is because you let it be so.",
19+
"Programming isn't about what you know; it's about what you can figure out.",
20+
"The happiest moment i felt; is that moment when i realized my ability to create.",
21+
];
22+
public function __construct(array $thoughts = null)
23+
{
24+
if ($thoughts) {
25+
$this->thoughts = $thoughts;
26+
}
27+
}
28+
/**
29+
* This method will generate random thought
30+
*
31+
*
32+
* @author Vladimir Nikolic <[email protected]>
33+
*
34+
* @return void
35+
*/
36+
public function getRandomThought(): string
37+
{
38+
return $this->thoughts[array_rand($this->thoughts)];
39+
}
40+
}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
<?php
2+
3+
namespace CodingWisely\Thoughts\Tests;
4+
5+
use CodingWisely\Thoughts\ProgrammingThoughtsFactory;
6+
use PHPUnit\Framework\TestCase;
7+
8+
class ProgrammingThoughtsFactoryTest extends TestCase
9+
{
10+
/**
11+
* This method will test if class returns a random joke
12+
*
13+
* @test
14+
*
15+
* @author Vladimir Nikolic <[email protected]>
16+
*
17+
* @return void
18+
*/
19+
public function it_returns_a_random_joke()
20+
{
21+
$thoughts = new ProgrammingThoughtsFactory([
22+
'This is a thought'
23+
]);
24+
$joke = $thoughts->getRandomThought();
25+
$this->assertSame('This is a thought', $joke);
26+
}
27+
}

0 commit comments

Comments
 (0)